Ayman Salah
Ayman Salah

Reputation: 1089

Dropdown depending on another collection_select rubyonrails

Guys that is my code thing is I want to select a parent subject and upon selection I need to use that selected subject to list the topics within it in the parent field how can i do that?

    <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>

Upvotes: 0

Views: 1191

Answers (1)

Dan Laffan
Dan Laffan

Reputation: 1554

Would this help? Rails dependent collection_select fields in form

If not, I am about to build something and might be happy to share it if it isn't to ugly!

Upvotes: 2

Related Questions