Rails Updating Nested Model Collection Select
- by Timothy
I have a contrived nested Rails form like the following
<% form_for @a do |fa| %>
<% fa.fields_for :b do |fb| %>
<% fb.fields_for :c do |fc| %>
<%= fc.label :option_id %>
<%= fc.collection_select :option_id, ModelD.all(:select => "id, name"), :id, :name %>
<% end %>
<% end %>
<% end %>
and then somewhere else on the same page I have a remote form
<% remote_form_for :modeld, ModelD.new, :url => new_modeld_path, :html => {:method => 'post'} do |f| %>
<%= f.label :name %>
<%= f.textarea :name %>
<%= f.submit "Create" %>
<% end %>
Is there any way I could update all the collection selects in the first form using Ajax when I submit the second form? There are an arbitrary number of collection selects.