I am working on a rails application but cannot find how to handle dependent dropdowns. I have 3 models: - A category that has several groups - A group that has several members - Member
When a category is selected, I would like the groups in this category to populate the second drop-down list (and the same between the group and the member).
I have the following view (obviously, this does not work, as I would like, when I take all the elements for a specific model) ...
<div class="field">
<%= f.collection_select(:category, Category.find(:all), :id, :name, {:include_blank => 'Category'}) %>
</div>
<div class="field">
<%= f.collection_select(:group, Group.find(:all), :id, :name, {:include_blank => 'Group'}) %>
</div>
<div class="field">
<%= f.collection_select(:member, Member.find(:all), :id, :name, {:include_blank => 'Member'}) %>
</div>
<div class="actions">
<%= f.submit %>
</div>
What would be the best way to make these fields dependent? I found several topics regarding this on the Internet, but could not find an answer.
source
share