Hey folks,
I'm just learning rails and I've run into a bit of a snag. Let me start with a simple breakdown of my application - it's a cookbook (of sorts)
- Recipes have one or more ingredients (tuna, spleens, etc)
- Ingredients have one unit (ounces, pounds, etc)
- Units are pulled from a lookup table
Here's a screenshot to help clarify things further: Form Mockup
Here's my issue: my collection_select elements names should be something like unit[id][]
Instead, they're all just named unit[id]
. Here's the snippet I'm using:
collection_select( :unit, :id, @units, :id, :name, options = { :prompt => "Please Select", :class => "ingredient_unit", :name => "unit[][]", :id => "unit:" + i.to_s() } );
However, this is what it is outputting:
<select id="unit_id" name="unit[id]"> <option value="">Please Select</option> <option value="1">Ounces</option> </select> ...
Now, in php, these dropdowns would be named unit[]
. Am I going about this the wrong way?
Thanks for the help