# Save information for parent child objects

**URL:** <https://www.ruby-forum.com/t/save-information-for-parent-child-objects/142228>\
**Category:** Rails\
**Created:** [July 4, 2008, 8:48pm UTC](https://www.ruby-forum.com/t/save-information-for-parent-child-objects/142228 "2008-07-04T20:48:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mitch\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@mitch\_newbie](https://www.ruby-forum.com/u/mitch_newbie)\
**Post date:** [July 4, 2008, 8:48pm UTC](https://www.ruby-forum.com/t/save-information-for-parent-child-objects/142228/1 "2008-07-04T20:48:32Z")

</div>

I have a user table and a user\_details table.

user\_details belongs\_to :user #user\_id foreign key in this table

user has\_one :user\_detail

I have two forms. First from collects details about the user:  
first\_name  
last\_name  
etc…

Then the login form where the user selects a username and password  
username  
password

I collect and validate the user details on the first form but don’t save  
them as I need to create the user.

I know there is a way to save to both tables after they pass validation.  
What would be the way to do this?

Is it something like

user \<\< user\_details

user.save

Thank you for your time in advance,

Mitch

---

<div class="post-metadata">

**Author:** ![mitch\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@mitch\_newbie](https://www.ruby-forum.com/u/mitch_newbie)\
**Post date:** [July 5, 2008, 12:39am UTC](https://www.ruby-forum.com/t/save-information-for-parent-child-objects/142228/2 "2008-07-05T00:39:20Z")

</div>

On 04 Jul 2008, at 20:48, Mitchell G. wrote:

> What would be the way to do this?
> 
> Is it something like
> 
> user \<\< user\_details
> 
> user.save
> 
> Thank you for your time in advance,

Check out Railscast episodes 73,74 and 75 on complex forms and read  
through validates\_associated in the Rails API documentation.

Best regards

Peter De Berdt
