I've followed the guide which is excellent, however, when I add has_secure_password to my user model: class User < ActiveRecord::Base attr_accessible :name, :email, :password, :password_confirmation has_secure_password
validates :name, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true,
format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
validates :password, length: { minimum: 6 }
validates :password_confirmation, presence: true
end
and then try to add a user via the rails console:
1.9.3-p125 :001 > User.create(name: "Michael Hartl", email: "mhartl@example.com",
1.9.3-p125 :002 > password: "foobar", password_confirmation: "foobar")
I receive a very lengthy error message that starts with:
/Users/username/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/bcrypt-ruby-3.0.1/lib/bcrypt_ext.bundle: [BUG] Segmentation fault ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]
-- Control frame information -----------------------------------------------
c:0058 p:-17575139500290 s:0220 b:0220 l:000219 d:000219 TOP
c:0057 p:---- s:0218 b:0218 l:000217 d:000217 CFUNC :require
and continues for many more lines...
If I take out "has_secure_password" from user.rb and try to create the same user as above I receive the following error:
ActiveRecord::UnknownAttributeError: unknown attribute: password
Finally, if I then insert "attr_accessor :password, :password_confirmation" into the model I can successfully add the user, however, the password_digest is nil.
I know I'm doing something wrong, however, I'm stumped.