# Forms with nesting/composite models

**URL:** <https://www.ruby-forum.com/t/forms-with-nesting-composite-models/117791>\
**Category:** Rails\
**Created:** [October 20, 2007, 9:49am UTC](https://www.ruby-forum.com/t/forms-with-nesting-composite-models/117791 "2007-10-20T09:49:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/3e96dc/32.png) [@elan](https://www.ruby-forum.com/u/elan)\
**Post date:** [October 20, 2007, 9:49am UTC](https://www.ruby-forum.com/t/forms-with-nesting-composite-models/117791/1 "2007-10-20T09:49:14Z")

</div>

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:

Person:  
has\_one :contact\_data

ContactData:  
belongs\_to: person  
has\_many :instant\_messengers  
has\_many :phone\_numbers

InstantMessenger:  
belongs\_to :contact\_data

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

Work

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.

Thanks,

-elan

---

<div class="post-metadata">

**Author:** ![elan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/3e96dc/32.png) [@elan](https://www.ruby-forum.com/u/elan)\
**Post date:** [October 20, 2007, 11:53pm UTC](https://www.ruby-forum.com/t/forms-with-nesting-composite-models/117791/2 "2007-10-20T23:53:22Z")

</div>

Hi Elan

Do you know Railscasts? ([http://railscasts.com/](http://railscasts.com/)) Ryan, in the last 3  
episodes (complex forms), shows how to do this kind of stuf.

Okada.

---

<div class="post-metadata">

**Author:** ![elan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/3e96dc/32.png) [@elan](https://www.ruby-forum.com/u/elan)\
**Post date:** [October 21, 2007, 10:02pm UTC](https://www.ruby-forum.com/t/forms-with-nesting-composite-models/117791/3 "2007-10-21T22:02:02Z")

</div>

Hey Carlos,

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

-elan
