Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails Select Form Tag - How to add a default "All" option?

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

like image 629
AnApprentice Avatar asked Jan 08 '11 03:01

AnApprentice


1 Answers

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' %>
like image 129
vonconrad Avatar answered Sep 23 '22 14:09

vonconrad