【发布时间】:2013-12-24 04:36:59
【问题描述】:
我终于想通了如何使用this tutorial 实现动态选择菜单。
一切正常,但是如何按名称组织下拉列表中的城市....
以下是我编写的所有代码。 (如果您需要更多信息,请告诉我)
Rails 新手请帮忙 :)
观看次数
<%= simple_form_for ([@book, @rating]) do |f| %>
<div class="field">
<%= f.collection_select :state_id, State.order(:name), :id, :name, {:include_blank=> "Select a State"}, {:class=>'dropdown'} %>
</div>
### I would like the order of the cities displayed in the drop down to be alphabetized
<div class="field">
<%= f.grouped_collection_select :city_id, State.order(:name), :cities, :name, :id, :name, {:include_blank=> "Select a City"}, {:class=>'dropdown'} %>
</div>
<% end %>
【问题讨论】:
标签: ruby-on-rails ruby simple-form grouped-collection-select