Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
mastering_aa/config/initializers/active_admin/filter_numeric_range_input.rb
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
31 lines (27 sloc)
870 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveAdmin | |
module Inputs | |
class FilterNumericRangeInput < ::Formtastic::Inputs::StringInput | |
include FilterBase | |
def to_html | |
input_wrapping do | |
[ label_html, | |
builder.text_field(gt_input_name, input_html_options(gt_input_name)), | |
template.content_tag(:span, "-".html_safe, :class => "seperator"), | |
builder.text_field(lt_input_name, input_html_options(lt_input_name)), | |
].join("\n").html_safe | |
end | |
end | |
def gt_input_name | |
"#{method}_gte" | |
end | |
alias :input_name :gt_input_name | |
def lt_input_name | |
"#{method}_lte" | |
end | |
def input_html_options(input_name = gt_input_name) | |
current_value = @object.send(input_name) | |
{ :size => 10, :id => "#{input_name}_numeric" , :value => current_value} | |
end | |
end | |
end | |
end |