# Nested object form existing values not displayed

**URL:** <https://www.ruby-forum.com/t/nested-object-form-existing-values-not-displayed/173571>\
**Category:** Rails\
**Created:** [August 11, 2009, 3:51pm UTC](https://www.ruby-forum.com/t/nested-object-form-existing-values-not-displayed/173571 "2009-08-11T15:51:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ingoweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@ingoweiss](https://www.ruby-forum.com/u/ingoweiss)\
**Post date:** [August 11, 2009, 3:51pm UTC](https://www.ruby-forum.com/t/nested-object-form-existing-values-not-displayed/173571/1 "2009-08-11T15:51:48Z")

</div>

I have two models, User and Profile, that have a one-to-one  
relationship and which I am creating in the same form. I thought I’d  
give nested object forms a go, but got stuck with two problems:

1. When I use the syntax from the tutorials I found,  
‘form.fields\_for :profile do |profile\_form|’, then the key of the  
resulting params hash is ‘profile’, and the User model seems to expect  
‘profile\_attributes’ instead. So I had to change the syntax to  
‘form.fields\_for :profile\_attributes do |profile\_form|’. Is this the  
way to go?

2. What is the best way to get the form fields to be pre-filled with  
existing profile attributes when the form comes back with validation  
errors? Shouldn’t that happen automatically? Maybe the fact that it  
isn’t is related to 1) somehow?

Thanks for any hint!  
ingo
