How can I set a default value using select_tag, and how can I keep the options open on page load?
Its already explained, Will try to give an example for achieving the same without options_for_select
let the select list be
select_list = { eligible: 1, ineligible: 0 }
So the following code results in
<%= f.select :to_vote, select_list %>
So to make a option selected by default we have to use selected: value.
<%= f.select :to_vote, select_list, selected: select_list.can_vote? ? 1 : 0 %>
if can_vote? returns true it sets selected: 1 then the first value will be selected else second.
select name="driver[bca_aw_eligible]" id="driver_bca_aw_eligible">
if the select options are just a array list instead of hast then the selected will be just the value to be selected for example if
select_list = [ 'eligible', 'ineligible' ]
now the selected will just take
<%= f.select :to_vote, select_list, selected: 'ineligible' %>