KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have been playing around with has_secure_password and I ran into a problem. My test for the create action in my UsersController was not working passing. So I started playing around in the console and realized that the password was not being converted to a has and saved in password_digest field. When I try to create a user from the console the following happens. irb(main):031:0> u = User.new(:email => "test1@test.com", :password => "test", :password_confirmation => "test") => #<User id: nil, email: "test1@test.com", password_digest: nil, created_at: nil, updated_at: nil> irb(main):032:0> u.save => false irb(main):033:0> u.errors => #<ActiveModel::Errors:0x00000100cde500 @base=#<User id: nil, email: "test1@test.com", password_digest: nil, created_at: nil, updated_at: nil>, @messages={:password_digest=>["can't be blank"]}> I am not sure what I am doing wrong. It looks like the password_digest attribute never gets assigned. If I create a user object with no attributes and assign each attribute individually I get the same error. Here is my model class User < ActiveRecord::Base has_secure_password attr_accessible :email, :password, :password_confirmation end Thanks for the help in advance. Alex Shenoy
Tags (comma-separated)
Save Edits
Cancel