5
我有资源订单。在我的管理面板(activeadmin)中,我需要一个布尔过滤器来获取用户具有特定角色的所有订单。Active Admin Rails4自定义筛选器与Ransack
在Order类我有这样一个范围:
class Order
belongs_to :user
scope :client_only_in, -> { joins(:user).where('users.role = ?', 'client') }
end
在主动管理order.rb我已经添加后续过滤:
filter :client_only, as: :check_boxes
使用Rails 3(元搜索)我可以添加
search_method :client_only_in, type: :boolean
得到过滤器,但与轨道4和Ransack我不知道如何做到这一点。
不添加search_method
到命令模式出现错误
undefined method `client_only_in' for Ransack::Search
当我访问索引管理订单页面。
任何帮助?
我无法在Rails 4中获得此项工作。以下是我找到的解决方案:http://cavewall.jaguardesignstudio.com/2014/05/01/activeadmin-filters -with-洗劫/ – smcdrc