rails search_form中select_tag的名称和ID

时间:2014-05-13 11:55:29

标签: ruby-on-rails ransack

如何在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 } %>

谢谢,

1 个答案:

答案 0 :(得分:2)

试试这个

select_tag "product_modules[product_id]", options_from_collection_for_select(Product.order(:name), :id, :name)