[英]Numeric custom filter with ransacker is not working
I am trying to make a new custom filter in ActiveAdmin of a rails application. 我正在尝试在Rails应用程序的ActiveAdmin中创建新的自定义过滤器。 When I put bellow code 当我输入下面的代码
filter :premium_scenes_in
it displays a input field as text input field (with option "contains", "equals" and etc) but I want an input field as numeric with option "equals", "greater than" or "less than". 它将输入字段显示为文本输入字段(带有选项“包含”,“等于”等),但我希望输入字段为带有选项“等于”,“大于”或“小于”的数字。
I tried to use: 我尝试使用:
filter :premium_scenes_in, as: :numeric
or filter :premium_scenes_in, as: :numeric_range
filter :premium_scenes_in, as: :numeric
或filter :premium_scenes_in, as: :numeric_range
But each time it shows an error Unable to find input class NumaricRangeInput
但是每次显示错误时Unable to find input class NumaricRangeInput
This is my code in model 这是我在模型中的代码
ransacker :premium_scenes,
formatter: proc { |number|
results = Tour.all.map{|tour| tour if tour.scenes.count > number}
results = results.present? ? results : nil
}, splat_params: true do |parent|
parent.table[:id]
end
I think you meant as: :number
. 我认为您的意思as: :number
。 The supported input types are documented in the Formtastic README here 支持的输入类型在此处的Formtastic自述文件中进行了说明
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.