下拉取决于另一个collection_select ruby​​onrails

时间:2014-10-13 15:36:58

标签: ruby-on-rails-4 collection-select

作为我的代码的人是我想选择一个父主题,在选择后我需要使用该选定的主题在父字段中列出其中的主题我该怎么做?

    <label>Parent Subject</label>
    <div class="field">
      <%= collection_select :topic, :subject_id, Subject.all, :id, :name %>
    </div>
    <label>Parent Topic</label>
    <div class="field">
      <%= collection_select :topic, :parent_id, ?????, :id, :name %>
    </div>

1 个答案:

答案 0 :(得分:2)

这会有帮助吗? Rails dependent collection_select fields in form

如果没有,我即将建立一些东西,如果它不丑,可能会很乐意分享它!

相关问题