我希望使用options_from_collection_for_select在我的下拉列表中包含空格,但似乎无法放入通常的集合参数{ :include_blank => true}
。我无法在任何地方找到这方面的参考。我错过了什么吗?我的发言是:
<%= select_tag "search", options_from_collection_for_select(TaskGroup.all.order("LOWER(task_group_name)"), "id", "task_group_name",params[:search]) %>
提前感谢您的帮助,
利亚
答案 0 :(得分:4)
试试这个:
<%= select_tag "search", options_from_collection_for_select(TaskGroup.all.order("LOWER(task_group_name)"), "id", "task_group_name",params[:search]), :include_blank => true %>
答案 1 :(得分:0)
试试这个:
<%= select_tag "search", options_for_select(TaskGroup.all.order("LOWER(task_group_name)").map {|task_group| [task_group.task_group_name, task_group.id]}, params[:search]), {include_blank: "Select task group"} %>