This works for me:
<%=
prompt = 'select person'
select_tag(
name = 'person',
options_for_select(
@names_array.unshift(prompt),
selected: prompt,
disabled: prompt,
)
)
%>
Although it seems to me that the: prompt option for the select_tag () helper should create <option>one that is disabled by default, so you can simply write:
select_tag(
name = 'person',
options_for_select(@names_array),
prompt: 'select name'
)
source
share