Back to Course

Reading the Source · Card 10

What does has_secure_password install?

One line. A whole authentication setup: virtual password attribute, hashing on assignment, an authenticate method, and validations. Plus one column requirement Rails won't budge on.

The familiar line

The Rails-canonical way to handle passwords. The model has a password_digest column.

class User < ApplicationRecord
  has_secure_password
end

The question

Name everything has_secure_password adds to a User instance and to the User class. Plus the one column requirement.

Take a moment. Think about: where the plain password lives, where the hashed password lives, how you set it, how you check it, and what validations come along for the ride.