我在ActiveAdmin资源页面中有一个过滤器:
filter :active_in, label: 'Active', as: :select, collection: ['All', 'Yes', 'No']
和ransacker:
ransacker :active, formatter: proc {|value|
results = Model.active.ids if value == 'Yes'
results = Model.inactive.ids if value == 'No'
results.present? ? results : nil
} do |parent|
parent.table[:id]
end
问题是,如果我选择全部'它应显示所有数据而不进行过滤,相反,如果它尝试使用' null'过滤模型'。
SELECT COUNT(count_column) FROM (SELECT 1 AS count_column FROM `models` WHERE `models`.`id` IN (NULL) LIMIT 50 OFFSET 0) subquery_for_count
对于'是'和'不'它工作正常。