title: undefined method `build_users' with nested models
body: <p>I've got into trouble with nested attributes.</p>
  
  <p>Here is my Account model : </p>
  
  <pre><code>class Account &lt; ActiveRecord::Base
  
      has_many :products
      has_many :blogs
      has_many :openings
      has_many :users
      has_one :logo, :class_name =&gt; "AccountPicture"
      has_one :address, :class_name =&gt; "AccountAddress"
      has_and_belongs_to_many :options
  
  
      accepts_nested_attributes_for :logo, :allow_destroy =&gt; true
      accepts_nested_attributes_for :address, :allow_destroy =&gt; true
      accepts_nested_attributes_for :users, :allow_destroy =&gt; true
  
  end
  </code></pre>
  
  <p>And here is my User model : </p>
  
  <pre><code>class User &lt; ActiveRecord::Base
      belongs_to :account
  end
  </code></pre>
  
  <p>As you can see, Account accepts nested attributes for logo, address, and users. </p>
  
  <p>While testing, i can use nested attributes for logo and address, but not for user.</p>
  
  <pre><code>a = Account.new
  
  =&gt; #&lt;Account id: nil, hostname: nil, subdomain: nil, name: nil, description: nil, base_line: nil, footer: nil, phone_number: nil, mobile_number: nil, email_address: nil, created_at: nil, updated_at: nil&gt;
  
  # building the address works fine
  &gt;&gt; a.build_address
  =&gt; #&lt;AccountAddress id: nil, account_id: nil, country: nil, state: nil, county: nil, city: nil, suburb: nil, zipcode: nil, street: nil, streetno: nil, longitude: nil, latitude: nil, error_code: nil&gt;
  
  # building the users fails
  &gt;&gt; a.build_users
  NoMethodError: undefined method `build_users' for #&lt;Account:0x7f6862a5f948&gt;
  from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:260:in `method_missing'
  from (irb):2
  </code></pre>
  
  <p>Thus, in my views, when i use the nested forms, i got this error back : </p>
  
  <pre><code>User(#69850615730460) expected, got Array(#69850664775200)
  </code></pre>
  
  <p>Any help would be appreciated.</p>
  
  <p>Thanks.</p>
  
  <p>EDIT : view </p>
  
  <pre><code>&lt;%= error_messages_for :account %&gt;
  
  &lt;% form_for :account, :url =&gt; accounts_path do |f| -%&gt;
  &lt;fieldset&gt;
    &lt;legend&gt;Account&lt;/legend&gt;
  
    &lt;%= label_tag 'name' %&gt;
    &lt;%= f.text_field :name, :class =&gt; "textbox" %&gt;
  
  &lt;/fielset&gt;
  
  &lt;% f.fields_for :users do |user_form| %&gt;
  
    &lt;fieldset&gt;
      &lt;legend&gt;User&lt;/legend&gt;
      &lt;%= label_tag 'email' %&gt;
      &lt;%= user_form.text_field :email, :class =&gt; "textbox" %&gt;
  
      &lt;%= label_tag 'password' %&gt;
      &lt;%= user_form.password_field :password, :class =&gt; "textbox" %&gt;
  
      &lt;%= label_tag 'password_confirmation' %&gt;
      &lt;%= user_form.password_field :password_confirmation, :class =&gt; "textbox" %&gt;
  
    &lt;/fieldset&gt;
  &lt;% end -%&gt;
  
  &lt;div class="buttons"&gt;
    &lt;%= submit_tag 'Submit', :class =&gt; "button" %&gt;
  &lt;/div&gt;
  &lt;% end -%&gt;
  </code></pre>