02 Oct 2012, 09:15
Generic-user-small

Maksym Kustov (1 post)

Hi.

I’m trying to create a new user and after clicking “Create User” button, I get the following message:

 ActiveModel::MassAssignmentSecurity::Error in UsersController#create

Can't mass-assign protected attributes: name, password, password_confirmation

File model\user.rb

class User < ActiveRecord::Base
	validates :name, presence: true, uniqueness: true
	has_secure_password
end

All my code was taken from eBook. What can be wrong with it?

05 May 2013, 22:11
Generic-user-small

Olivier Le Cam (1 post)

Pay attention to also set attr_accessible in the model to make it to work.

model/users.rb:

attr_accessible :name, :password, :password_confirmation

HTH

  You must be logged in to comment