I am using the following to allow my users to select their sex in their profile.
<%= f.select (:sex, %w{ Male Female }) %>
How would I c
There are two possibilities, depending on what you're after:
include_blank<%= f.select (:sex, %w{ Male Female }, :include_blank => true) %>
This will always include a blank option in the select, which will allow people to set the value back to the blank value if they're seeing this on an edit form.
prompt<%= f.select (:sex, %w{ Male Female }, :prompt => "Gender...") %>
This will include the specified prompt value, so long as the field hasn't already been set. If it has (on an edit form for example), there's no need to remind the user that they need to select a value so the prompt doesn't appear