我不确定我做错了什么,但我的select_tag :selected
无效。检查以下代码:
<%= select_tag :supplier, options_from_collection_for_select(SupplierItem.select("DISTINCT(SUPPLIER)").group("SUPPLIER"), "SUPPLIER", "SUPPLIER"), { :selected => params[:supplier], prompt: "Select a Category"} %>
答案 0 :(得分:2)
我让:selected => params[:supplier]
在错误的地方。下面的工作代码:
<%= select_tag :supplier, options_from_collection_for_select(SupplierItem.select("DISTINCT(SUPPLIER)").group("SUPPLIER"), "SUPPLIER", "SUPPLIER" ,:selected => params[:supplier]), {prompt: "Select a Category"} %>
答案 1 :(得分:0)