我希望能够在活动管理员中过滤设计用户,以便我可以显示用户列表,然后按他们拥有的角色过滤这些用户。
我所拥有的是:
class User < ActiveRecord::Base
has_many :user_permissions
has_many :roles, :through => :user_permissions
class Role < ActiveRecord::Base
has_many :user_permissions
has_many :users, :through => :user_permissions
class UserPermission < ActiveRecord::Base
belongs_to :user, :dependent => :destroy
belongs_to :role
那么过滤器是:
ActiveAdmin.register User do
filter :roles, as: :select, collection: proc { Role.all }
但我得到的是这个错误:
undefined method `role_ids_eq' for #<MetaSearch::Searches::User:0x0000012a2f7170>