Controller/view changes for editing nested forms?

I’ve successfully set up a nested form from the controller:

def new
@user = User.new
@user.build_contact.build_address

respond_to do |format|
  format.html # new.html.erb
  format.xml  { render :xml => @user }
end

end

and have edited the new.html.erb file to suit, with fields_for in the
appropriate places. The form successfully creates contact and address
records
when saved, and I can see linked objects when I simply create them at
the
console. However, selecting edit from the index brings up the
edit.html.erb
view (practically identical to new.html.erb) but isn’t populating the
nested
fields–only the ones from User get populated, but Contact and Address
remain blank even though the records exist.

Do I need to change something in the edit() to populate the fields for
the nested objects? I currently have:

def edit
@user = User.find(params[:id])
end

Or do I need to change the view somehow to access the nested objects
differently when I edit than I do when I create?


“Oh, look: rocks!”
– Doctor Who, “Destiny of the Daleks”