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])