vanilla_skies
vanilla_skies

Reputation: 415

dynamic select for menu

I am trying to select a SuperCategory which then filters the drop down for MainCategories. I am getting the following error

undefined method `map' for :main_categories:Symbol

with the code

<%= select_tag 'main_category_id', grouped_collection_select(:main_category_id, SuperCategory.active.order(:title), :main_categories, :title, :id, :title, include_blank: false) %>

Upvotes: 0

Views: 38

Answers (2)

vanilla_skies
vanilla_skies

Reputation: 415

this ended up working for

<%= grouped_collection_select('grouped', :main_category_ids, SuperCategory.exclude_most_popular, 'sort_main_categories', :title, :id, :title, {  :selected => selected_main, include_blank: false } ) %>

Upvotes: 0

kunashir
kunashir

Reputation: 949

I think you must change second and third parameters. Because: 2 parameter - method - The attribute of object corresponding to the select tag 3 parameter - collection - An array of objects representing the tags.

In your code third parameter is Symbol and it's doesn't have method "map".

http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/grouped_collection_select

Upvotes: 1

Related Questions