Rails 3.2上的grouped_collection_select

时间:2014-03-04 19:56:09

标签: ruby-on-rails-3.2

如何将此选择显示为分组集合选择。我尝试了各种不同的类型,但没有用。任何帮助表示赞赏。

enter image description here

<%= f.select :agency_type_id, AgencyType.joins(:sector).order('sectors.name ASC, name ASC').map {|atype| ["#{atype.sector.name}  -  #{atype.name}", atype.id]}, :prompt => "Select Sector  -  Agency Type" %>

我想通过分组行业显示代理商类型。
例如:
大弯
联邦LEA
当地LEA
Del Rio
联邦LEA
当地LEA
等等...

1 个答案:

答案 0 :(得分:0)

在摆弄API之后,我得到了解决方案:

<%= f.grouped_collection_select :agency_type_id, Sector.order('name ASC'), :agency_types, :name, :id, :name, :prompt => "Select Agency Type" %>
相关问题