从表单中的集合选择中将多个属性提交到控制器



我希望在提交表单时,在 rails 中使用集合选择标记将所选项目的两个属性提交给控制器。基本上,我有一个县列表,我想提交县和州作为参数。让它提交一个或另一个没有问题,但不能同时提交两个。我是否想错了?这是我到目前为止所拥有的...

<%= form_tag(plans_path, method: 'get', action: 'screen2') do %>
    <%= text_field_tag :ZIP, "ZIP Code", id: "zipBlur"%>
    <%= collection_select(nil, :county, @counties.order('RES_RATIO DESC'), :COUNTY, :COUNTY_NAME, {:selected => "#{params[:county]}"}) %>
    <%= submit_tag 'Screen', :name=> nil %> 
<% end %>

感谢您的帮助!

使用:multiple => true

前任:

<%= collection_select(:ingredient, :supplier_ids, 
              Supplier.all(:order=>"name ASC"), 
              :id, :name, {:selected => @ingredient.supplier_ids, :include_blank => true}, {:multiple => true}) %>

最新更新