2016-11-22 63 views
0

如何提供与组关联的收集用户?如何向Activeadmin嵌套资源过滤器提供集合?

has_many :users, through: :group_settings 
has_many :groups, through: :group_settings 

ActiveAdmin.register Group do 
    ActiveAdmin.register GroupSetting do 
    belongs_to :group 
    filter :user_email, as: :select, collection: Users.????, label: 'Email' 
    end 
end 

谢谢!

在你的模型:

has_and_belongs_to_many :groups

scope :with_group_id, ->(group_id) { joins(:groups).where(groups: {id: [*group_id] }) }

与用法:

User.with_group_id([2,5])

回答

0

的情况下,当你的用户可以属于多个组解决方案其中2和5 - 组标识