# Nested Object Forms

**URL:** <https://www.ruby-forum.com/t/nested-object-forms/164867>\
**Category:** Rails\
**Created:** [April 6, 2009, 8:54pm UTC](https://www.ruby-forum.com/t/nested-object-forms/164867 "2009-04-06T20:54:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neal\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/74df32/32.png) [@Neal\_L](https://www.ruby-forum.com/u/Neal_L)\
**Post date:** [April 6, 2009, 8:54pm UTC](https://www.ruby-forum.com/t/nested-object-forms/164867/1 "2009-04-06T20:54:38Z")

</div>

Hi all,

I’m trying to use nested object forms for the signup page of an app to  
create the client record as well as the admin user. My problem is  
that everything in the fields\_for the associated record is not getting  
rendered from the view – not the fields, not the html, nothing.

How can I make sure that when the user submits the form that the user  
is also submitted???

Code:

\<% form\_for(@client) do |client\_form| %\>  
\<%= client\_form.text\_field :company\_name %\>  
…  
\<% client\_form.fields\_for :users do |user\_form| %\>  
  
Admin Account  
Username: \<%= user\_form.text\_field :login %\>  
…  
\<% end %\>  
…  
\<% end %\>

---

<div class="post-metadata">

**Author:** ![Neal\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/74df32/32.png) [@Neal\_L](https://www.ruby-forum.com/u/Neal_L)\
**Post date:** [April 7, 2009, 4:59am UTC](https://www.ruby-forum.com/t/nested-object-forms/164867/2 "2009-04-07T04:59:52Z")

</div>

I believe that you are trying to allow multiple administrator accounts  
to be added when creating a company.

To do so, you will need multiple fields\_for as you cannot just do this  
for a collection. Looking at it, it looks like it should give an error  
instead of just displaying nothing. Actually I don’t know if you can  
use a collection, rails surprises you very often with what it can do  
and I bet someone has a solution that can do just that.

Otherwise, the solution depends on what version of rails you are  
using:

Rails 2.3  
[http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes](http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes)

Rails 2.2 and below  
[http://railsforum.com/viewtopic.php?id=719](http://railsforum.com/viewtopic.php?id=719)
