Hi, all,
I setup a drop down box that has data populated by the database.
This is for a simple application where by I am trying to add a new "Part". A part has a category and sub category. The latter is optional.
When a category has been selected, an ajax query is made to the database backend to extract the subcategory options available for the selected category.
This has been implemented and works great for the task of adding a new "Part" entry (ie. http://localhost:3000/parts/new) .
I did it by refering to the explanation in http://shiningthrough.co.uk/blog/show/6. It was good.
Nevertheless, when I need to edit a given part (ie. http://localhost:3000/parts/22/edit), I keep getting this silly error message below. "undefined method `map' for "#<Category:0x103231d20>":Category".
This is the full extract of the error messages:
============Extract Begin=============================== NoMethodError in Parts#edit
Showing app/views/categories/_form.html.erb where line #3 raised:
undefined method `map' for "#<Category:0x1036113c8>":Category
Extracted source (around line #3):
1: <%= label :category, :id, 'Category' %> <br /> 2: <%= collection_select( 3: :part, 4: 'category_id', 5: @categories, 6: :id,
Trace of template inclusion: app/views/parts/edit.html.erb ============Extract End===============================
Here's what my other files look like:
app/views/parts/new.html.erb