grouped_options_for_select --- include a select all
Hi,
I have Categories and CategoryType. A Category has_many CategoryTypes. In my form, I am using grouped_options_for_select to display the different category types for a category.
Form:
<%= f.select :category_type_id, grouped_options_for_select(@grouped_category_type_options), {'data-width' => "100%", include_blank: 'Categories'}, {:class => "form-control border-0 shadow-0 transparent-form"} %>
Being set in the controller:
@grouped_category_type_options = CategoryType.includes(:category).inject({}) do |options, type|
(options[type.category.name] ||= []) << [type.name, type.id]
options
What I want to know is that is there a way for me to also include an "all" option for the user to select "all" the category types for a set category. For example, for the category of "Hotels," the category types are "Hostel", "B&B", and "Motel". I want to also include an "All" option that will allow me to filter for all hotels regardless of the set category type.
Can anyone help me with this or point me in the right direction?
Thanks!