has_secure_password
suggest changeCreate User Model
rails generate model User email:string password_digest:string
The password_digest column is required. Add gem "bcrypt" to the Gemfile. has_secure_password uses it to hash the password.
Add has_secure_password to the User model
class User < ActiveRecord::Base
has_secure_password
end
Create a user with a password and a matching confirmation:
user = User.new email: 'bob@bob.com', password: 'Password1', password_confirmation: 'Password1'
authenticate returns the user when the password matches, and false when it does not:
user.authenticate('somepassword')
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents