我有兩個collection_select下拉當前設置像這樣的菜單:只列出唯一值
<div class="field">
<%= f.label :country_cont, "Country" %>
<%= f.collection_select(:country_cont, Country.all, :country, :country) %>
</div>
<div class="field">
<%= f.label :city_cont, "City" %>
<%= f.collection_select(:city_cont, Job.all, :city, :city) %>
</div>
我想是下拉只能從我的數據庫表顯示唯一值的列表(例如在城市中,而不是在倫敦展示5次,因爲有5個行有該城市,我希望倫敦只列出一次)。
任何意見,將不勝感激! :)
不錯!忘了你可以做到這一點。 –