Adding nested object in form using AJAX

Hi,

I'm using a nested form to create an object. It looks something like
this:

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 }
  end
  # here a link to create a new child object
end

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 http://github.com/alloy/complex-form-examples