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