【发布时间】:2015-12-24 16:31:19
【问题描述】:
您好,2015 年节日快乐 --
我尝试根据Boris Stall 的优秀博文添加数字范围过滤。
我在跑步:
- Rails 4.2.4
- Ruby 2.2.3
- ActiveAdmin 1.0.0pre2
我一直遇到这个错误:
找不到输入类 NumericRangeInput
这是我的配置/initializers/active_admin/filter_numeric_range_input.rb
module ActiveAdmin
module Inputs
class FilterNumericRangeInput < ::Formtastic::Inputs::StringInput # Add filter module wrapper
include ActiveAdmin::Inputs::Filters::Base
def to_html
input_wrapping do
[ label_html,
builder.text_field(gt_input_name, input_html_options(gt_input_name)),
template.content_tag(:span, "-", :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}_gteq"
end
alias :input_name :gt_input_name
def lt_input_name
"#{method}_lteq"
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
我只是在尝试:
filter :id, as: :numeric_range
我已经研究了集成 AA、Ransack、Formtastic 等的潜在问题,但我还不够先进,不知道从哪里开始。非常感谢任何帮助。
【问题讨论】:
标签: activeadmin formtastic ransack numeric-ranges