如何根据rails中的另一个下拉列表选择选择下拉列表项?

时间:2015-10-29 10:02:06

标签: ruby-on-rails erb form-helpers

我想根据另一个下拉列表中的选项来过滤下拉列表项

<%= form_tag("/myAdmin", method: "post") do %>
    <%= label_tag(:role_id, "Role: ")%>
    <%= select_tag('Role', options_for_select(Role.all.map(&:name)))  %> <br/>
    <%= label_tag(:school_id, "School: ")%>
    <%= select_tag('School', options_for_select(School.all.map(&:name) )) %> <br/>
    <%= label_tag(:grade_id, "Grade: ")%>
    <%= @grade = Grade.all
        @grade1 = @grade.map {|a| if a.school_id == :school_id a}
        select_tag('Grade', options_for_select(@grade1.map(&:name) ))  %> <br/>

<%= submit_tag("Submit") %>
<% end %>

这是一个包含3个删除列表的表单。

我想根据所选择的学校过滤年级列表..

成绩模型有{school_id和name attributes},学校模型有{organization_id和name attributes}

我该怎么做?

0 个答案:

没有答案