I have defined has_and_belongs_to_many associations between Meals and Recipes. In the Meals create form, I am using a select to populate the recipes.
<%= f.select :recipes, Recipe.all.collect { |x| [x.name, x.id]}, {}, :multiple => true %>
But the result set has a nil as the first value.
"recipes"=>["", "2", "7"]
How can I eliminate the empty/nil value?
For me setting :include_hidden => false
is what worked
<%= f.select :recipes, Recipe.all.collect { |x| [x.name, x.id]}, {:include_hidden => false}, :multiple => true %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With