2016-11-22 5 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 

ありがとうございます!ケースのため

答えて

0

ソリューションユーザーが複数のグループに属していることがあります。

モデルでは:

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

ここで、2および5 - グループID

関連する問題