tried to create simple dropdown in ruby with values from the database – like that :
<% ingredientArray = Ingredient.all.map { |ingredient| [ingredient.name, ingredient.id] } %>
<div class="field">
<%= select_tag(:ingredient_id, ingredientArray) %><br/>
</div>
and I received an empy one.
this is the generated html
<div class="field">
<select id="ingredient_id" name="ingredient_id">[["Paprika", 5], ["Cinnamon", 8], ["Salt", 9], ["Pepper", 10], ["water", 11]]</select><br/>
</div>
where should I put html sage
You should read documentation on select_tag and related methods.
The second parameter of it is a string containing the option tags for the select box.
You can generate in manually:
Or use options_from_collection_for_select method for it:
(Examples from the docs)
Specifically in your case the best way to make that dropdown is: