Atribut :selected in select_tag
-
There's a choice:
<%= select_tag('group_by', options_for_select([[]] + @query.groupable_columns.collect {|c| [c.caption, c.name.to_s]}, @query.group_by)) %>
Tell me how to add an attribute.
:selected
to be default empty, that is.:selected => ""
?
-
Add the third halper parameter.
select_tag
Attributioninclude_blank: true
as a result, you will automatically add to the beginning of an empty line that will be chosen by default<%= select_tag('group_by', options_for_select(@query.groupable_columns.collect {|c| [c.caption, c.name.to_s]}), include_blank: true) %>