A product belogs_to category. A category has_many products
I need a select tag that includes the optgroup tag.
So basically, I need my HTML markup to something similar to pseudo code:
<select name="product" class="products">
<option value=""></option>
<optgroup label="Cheese">
<option value="1">cheese 1</option>
<option value="2">cheese 2</option>
<option value="3">cheese 3</option>
</optgroup>
<optgroup label="Juices">
<option value="3">juice 1</option>
<option value="4">juice 2</option>
<option value="5">juice 3</option>
</optgroup>
</select>
Based on my models, how would I generate the array to put into grouped_options_for_select? For example, what is the best approach to generate grouped_options?
<%= select_tag 'product', grouped_options_for_select(grouped_options), :include_blank => true , :id => nil, :class => 'product' %>