独自のスコープを展開する必要があります。ActiveAdminは、フィルターにmeta_searchを使用します(https://github.com/ernie/meta_search)。
管理ファイル内:
filter :child_id_all,
:as => :check_boxes,
:collection => proc { Child.all }
filter :child_id_all_not,
:as => :check_boxes,
:collection => proc { Child.all }
親モデルの場合:
scope :child_id_all_in, -> ids {
ids.reduce(scoped) do |scope, id|
subquery = Parent.select('`parents`.`id`').
joins(:childs).
where('`childs`.`id` = ?', id)
scope.where("`parents`.`id` IN (#{subquery.to_sql})")
end
}
scope :child_id_all_not_in, -> ids {
ids.reduce(scoped) do |scope, id|
subquery = Parent.select('`parents`.`id`').
joins(:childs).
where('`childs`.`id` = ?', id)
scope.where("`parents`.`id` NOT IN (#{subquery.to_sql})")
end
}
search_methods :child_id_all_in
search_methods :child_id_all_not_in