Display selected option when editing a form (Rails 4)
<%= f.select(:condition, options_for_select([["Brand New", "Brand New"], ["Pre-owned", "Pre-owned"]], :selected => f.object.condition), :include_blank => true) %>
Check the options_for_select
documentation, and you will discover that the last parameter is the selected option.
options_for_select(container, selected = nil)
In your case
<%= f.select(:condition, options_for_select([["Brand New", "Brand New"], ["Pre-owned", "Pre-owned"]], params[:condition]), :include_blank => true) %>
assuming params[:condition]
contains the currently selected value, and the value matches the corresponding value in the select tag.
In other words, for "Pre-owned"
to be selected, params[:condition]
must contain "Pre-owned"
.