I have an f.select in the new article page, and it works fine. However, when I edit the article, the value changes back to whatever is first in the options.
Is there a way to keep the select value so users don't have to worry about redoing that when editing their article?
Here is my select tag:
<%= f.select :category,
options_for_select(['drink','food','medicine','supplement','drug','ingredient','lifestyle','other'], params[:category]), {}, { :class => 'span3 controls controls-row' } %>
Instead of
params[:category]
you should provideselected: :category
in theoptions_for_select(<...>)
.