Search code examples
ruby-on-railsruby-on-rails-4simple-form

simple_form grouped_select group_method with filtered data


Is it possible to filter data of the group_method in a grouped select in simple form??

<%= f.association :user,
                  collection:companies,
                  as: :grouped_select,
                  group_method: :users%>

I just want to be able to insert some of the users not all of them those who are linked to a project another model that i have.


Solution

  • It's not possible to filter using simple_form's group_method. Even if it was possible, I would be inefficient. What you need instead is to filter companies, which have only those users who is involved in the project.