has_secure_password

suggest change

Create 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')

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents