Forms with nesting/composite models

I was wondering how best to handle forms where I’m presenting a model
and some of its “children”, i.e. a Person with multiple IM contacts or
something. I had a look at some of the source in HighriseHQ, figuring
hey, if anybody knew how to do it it was David himself, and I noticed
something interesting. The models are roughly like this:

has_one :contact_data

belongs_to: person
has_many :instant_messengers
has_many :phone_numbers

belongs_to :contact_data

If you look at the form when editing a person, you see stuff like


and even more nested, this:

So as you can see, it looks like this can basically get slurped up by
the controller and probably in one fell swoop everything is either
updated or created.

So my question is, how did the Gods of Rails pull this off? It looks
like functionality that would find a happy place in the framework, but
I don’t think I’ve seen it anywhere.



Hi Elan

Do you know Railscasts? ( Ryan, in the last 3
episodes (complex forms), shows how to do this kind of stuf.


Hey Carlos,

Thanks a lot for the tip, that’s exactly what I was looking for!