Adding nested object in form using AJAX


I’m using a nested form to create an object. It looks something like

form_for @object do |f|
f.label :name
f.text_field :name
fields_for :child_object do |child_form|
render :partial => ‘child_form_part’, :locals => { :form =>
child_form }

here a link to create a new child object


Now, as you can see, I want to use an AJAX link to add a new child
object to the form and show its partial in addition to the children
that are already there. However, I don’t know how to do that. I can
use RJS to add the partial to the form using insert_html, but I’m not
sure how to pass along the local form object so I can build the form
in the partial.

Is there a good way to do this?

Thank you.

Yea i had to do the same thing, check here