I want to have my select_tag default to blank but i'm using a map
<%= select_tag "assignment[client_id]", options_for_select(@data.map{|d| ["#{d.first_name} #{d.last_name}",d.id]}, " ") %>
I know you can't use include_blank and you can't put " " to set开发者_Python百科 it to blank. any ideas ?
Thanks, Alex
Rails provides the select
helper method, which has a :include_blank
option, use like:
<%= select("assignment", "client_id", @data.map { |d| ["#{d.first_name} #{d.last_name}", d.id] }, { :include_blank => true }) %>
See the Rails' FormOptionsHelper#select for more informations.
PS: OT: Maybe add a def name; "#{first_name} #{last_name}" end
method to your model :)
精彩评论