I'm trying to create a user model that uses has_secure_password
, I've followed examples from the Rails documentation and it still fails.
This is my model:
class User < ActiveRecord::Base
attr_accessible :username, :email, :full_name, :password_digest
has_secure_password
end
And I'm trying to create a user like so:
@user = User.new({
username: params[:user][:username],
password: params[:user][:password],
password_confirmation: params[:user][:password_confirmation],
email: params[:user][:email],
full_name: params[:user][:full_name]
})
# I even tried with `@user.new(params[:user])`
However I'm getting this error:
Can't mass-assign protected attributes: password, password_confirmation
I've tried searching for solutions on here and google, taken a look at "sample apps" and I appear to be doing the same as they are, except that I'm still getting the error.
Is there something I'm doing wrong or missing?