In my form I have a f.association field:
<%= f.association :groups, as: :check_boxes %>
Now, I get a list of check boxes with all groups that are in my database. I would like to show only some of the groups using a where filter.
<%= f.association :groups, Group.where(type: 'products'), as: :check_boxes %>
But this does not work.
How can I do this?
Formtastic should allow you to define the collection with the :collection
key.
<%= f.association :groups, as: :check_boxes, collection: Group.where(type: 'products') %>
More examples can be found in their codebase here