One question about Dynamic Select Menus

Daniel
Thu, 25 Dec 2008 05:20:00 -0000

Hi all,
Merry X''mas first :-)

I have "Product","Category","Subcategory" 3 Model,
and when new
"Product", I want to use "Dynamic Select Menus" just like
Ryan
mentioned in http://railscasts.com/episodes/88-dynamic-select-menus

I have everything down. But when I visit the js file, I got following
error

Showing app/views/javascripts/dymanic_categories.js.erb where line #3
raised:

You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each

Extracted source (around line #3):

1: // javascripts/dynamic_categories.js.erb
2: var subcategories = new Array();
3: <% for subcategory in @subcategories -%>
4:   categories.push(new Array(<%= category.id %>, ''<%=h
subcategory.subcategory_name %>'', <%= subcategory.id %>));
5: <% end -%>


Anyone got an idea, how does it happen?