如何在select_tag上输入姓名和ID?我试过这种方式,但我只有语法错误,
<%= select_tag :product_id, options_from_collection_for_select(Product.order(:name), :id, :name, params[:product_modules][:product_id]), id: "product_modules[product_id]", { include_blank: true } %>
谢谢,
答案 0 :(得分:2)
试试这个
select_tag "product_modules[product_id]", options_from_collection_for_select(Product.order(:name), :id, :name)