Include blank for first item in select list in options_for_select tag
问题 I tried :include_blank => true , but it didn't work. <select> <%= options_for_select Model.all.collect{|mt| [mt.name, mt.id]} %> </select> If I need to add it to the collection, how would you do that? 回答1: I think you want this format: select("model_name", "model_id", Model.all.collect {|mt| [ mt.name, mt.id ] }, {:include_blank => 'name of your blank prompt'}) BTW: was assuming Modle was suppose to be Model. To use using collection_select: collection_select(:model, :model_id, Model.all, :id,