Can't mass-assign protected attributes: user
- by Ben Aluan
I'm working on a simple app that requires me to submit a form. I created two models.
user.rb
class User < ActiveRecord::Base
attr_accessible :email
has_many :item
end
item.rb
class Item < ActiveRecord::Base
attr_accessible :user_id
belongs_to :user
end
Instead of creating a user using the user form view, I'm trying to create the user using the item form view.
items/_form.html.haml
= nested_form_for @item do |form|
= form.fields_for :user do |builder|
= builder.text_field :email
= form.submit "Save"
Did I miss something here? I'm using nested_form_for btw. Thank you.