I have the following which creates a select box:
<%=select_tag "people", options_from_collection_for_select(@people, "id", "name")%>
This creates an item for each person, problem is I would like a "All People" value 0, option added and selected by default on load?
does the select_tag in rails 3 support this?
Thanks
Simply include a :include_blank => 'All People'
option in your select_tag
:
<%= select_tag "people", options_from_collection_for_select(@people, "id", "name"), :include_blank => 'All People' %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With