Reputation: 5104
So I have a couple models user and memoir.
User.rb
has_many :memoirs
accepts_nested_attributes_for :memoirs
attr_accessible :email, :password, :password_confirmation, :memoir_attributes
attr_accessor :password
before_save :encrypt_password
validates_confirmation_of :password
validates_presence_of :password, :on => :create
validates_presence_of :email
validates_uniqueness_of :email
and Memoir.rb
belongs_to :user
attr_accessible :user_id, :content, :birth, :death, :name, :subdomain
validates_uniqueness_of :subdomain
However when I save (the memoir is nested inside the user form) I get this message and the memoir doesn't save: "WARNING: Can't mass-assign protected attributes: memoir"
Confused
Upvotes: 1
Views: 2243
Reputation: 12867
You have
has_many :memoirs
and
accepts_nested_attributes_for :memoirs
So surely
attr_accessible :email, :password, :password_confirmation, :memoir_attributes
Should be
attr_accessible :email, :password, :password_confirmation, :memoirs_attributes
?
If I have that wrong then check your log file. That should tell you what the issue is
Upvotes: 3