# Nested Forms - how to displayed the attributes content?

**URL:** <https://www.ruby-forum.com/t/nested-forms-how-to-displayed-the-attributes-content/171409>\
**Category:** Rails\
**Created:** [July 2, 2009, 12:05am UTC](https://www.ruby-forum.com/t/nested-forms-how-to-displayed-the-attributes-content/171409 "2009-07-02T00:05:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [July 2, 2009, 12:05am UTC](https://www.ruby-forum.com/t/nested-forms-how-to-displayed-the-attributes-content/171409/1 "2009-07-02T00:05:34Z")

</div>

I have a User model

class User \< ActiveRecord::Base  
has\_one :account  
accepts\_nested\_attributes\_for :account, :allow\_destroy =\> true  
validates\_associated :account  
attr\_accessible :account\_attributes

is working fine, validating and updating both records (User and  
Account), but I caanot display the value in the form when is updated,  
ex: below the firstname is not displayed but it’s in the db account  
record  
#\<User id: 1, email: “removed\_email\_address@domain.invalid”, …  
#\<Account id: 4, user\_id: 1, title: 0, first\_name: “Yves”, …

my view  
…  
\<% form\_for :user, :url =\> { :action =\> “update” } do |user\_form|  
%\>  
\<% user\_form.fields\_for :account\_attributes do |account\_fields| %\>

```
    <li>
    <label for="user_firstname">First Name</label>
    <%= account_fields.text_field :first_name, :size => "30" %>
  </li>

```

…

what am I missing ?

thanks for your help

erwin

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [July 2, 2009, 1:18am UTC](https://www.ruby-forum.com/t/nested-forms-how-to-displayed-the-attributes-content/171409/2 "2009-07-02T01:18:22Z")

</div>

> …  
> \<% form\_for :user, :url =\> { :action =\> “update” } do |user\_form|  
> %\>

WRONG need to be :

form\_for :user, @user, :url =\> { :action =\> “update” } do |user\_form|

Ooops !

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [July 2, 2009, 1:18am UTC](https://www.ruby-forum.com/t/nested-forms-how-to-displayed-the-attributes-content/171409/3 "2009-07-02T01:18:37Z")

</div>

Discover the issue : I had to write correctly my form\_for

\<% form\_for :user, @user, …

and not \<% form\_for :user

Oops
