views:

251

answers:

2

Hi, I'm getting an error when I submit the form http://pastie.org/846712 I tried changing "f.fields_for :users do |builder|" to "f.fields_for :user do |builder|", but it generated nothing.

To give you a picture of how my accounts controller looks like: http://pastie.org/846714 And the error I'm getting is on: http://pastie.org/846715

Thanks, Emil.

+1  A: 

Have you added accepts_nested_attributes_for in your Account model? i.e.

class Account < ActiveRecord::Base
  has_many :users
  accepts_nested_attributes_for :users
end

Watch these screen casts below for more information about nested forms.

  1. Nested Model Form Part 1

  2. Nested Model Form Part 2

KandadaBoggu
Sorry, forgot to mention that. Yes, I did.
Emil Hajric
A: 

The user variable in your Account Controller's new method might be causing this error. Instead of setting a user variable, you might just want to do what Ryan Bates does in his Rails cast video:

 def new
    @account = Account.new
    # instead of this
    # user = @account.users.build 

    #use this
    1.times { @account.users.build }

    respond_to do |format|
      format.html # new.html.erb
      format.js { render :layout => false }
    end
  end
kelly.dunn