Ruby on rails 如何使用“其他选择”中的选定值从“选择”中筛选模型?
我正在使用一个Ruby on rails 如何使用“其他选择”中的选定值从“选择”中筛选模型?,ruby-on-rails,ruby-on-rails-4,simple-form,Ruby On Rails,Ruby On Rails 4,Simple Form,我正在使用一个simple\u form\u用于和select from Model。我想使用“其他选择”中的选定值筛选我的一些选择 这是我的密码: <%= simple_form_for @location do |f| %> <%= f.select :state_id, State.all.map { |c| [c.name, c.id] } <%= f.select :country_id, Country.where(state_id: params[:
simple\u form\u用于
和select from Model。我想使用“其他选择”中的选定值筛选我的一些选择
这是我的密码:
<%= simple_form_for @location do |f| %>
<%= f.select :state_id, State.all.map { |c| [c.name, c.id] }
<%= f.select :country_id, Country.where(state_id: params[:state_id]).map { |c| [c.name, c.id] }
<%= f.select :town_id, Town.where(country_id: params[:country_id]).map { |c| [c.name, c.id] }
<%= f.submit 'Save', class: 'btn btn-primary' %>
<% end %>
你想实现动态下拉吗?我还不知道动态下拉。我刚刚检查了你的url建议。我想这就是我需要的。