My tag:
<%= select_tag(:option, options_for_select([['All', 1], ['Co', 2], ['Bought', 3], ['View', 4], ['Top API', 5], :selected => :option ])) %>
How do I set the selected value to which option is selected. For example, if I select ['Bought', 3]
, and submit, ['All', 1]
option is selected. How can I display the selected value after the form is submitted.
['Bought', 3]
in the browser and then submit, where are you seeing that['All', 1]
was selected? Can you show the rest of the form as well as the controller code relevant for the form action? – Histogen]
) in the wrong place, so the browser see:selected => :option
as one option. Fixing the problem, you can refresh the browser and the selected option will remain selected. – Kurman