Hi.
I’ve searched but with no avail for a solution to my problem.
Basically, I’m trying to create a collection select on a parent-child
many_to_many relationship (in this case a product has and belongs to
many categories)
currently, I’ve got as far as:
<% form_for :product, product, :url => { :action => ‘set_status’, :id
=> product } do |f| %>
…
<% 0.upto(product.categories.size) do |i| %>
<% fields_for "categories[#{i}]", product.categories[i] do |cat| %>
<%= cat.collection_select( :id, @category_select_collection, :id,
:select_option_text, {:prompt => ‘Select category’}) %>
<% end %>
<% end %>
…
<% end %>
But I get the error: `@categories[0]’ is not allowed as an instance
variable name. What’s the most ‘Rails’ way to handle this?