has_secure_password
やってること
password=パスワードをBCryptを使ってハッシュ化して保存する authenticate 認証
バリデーション
code:ruby
class User < ActiveRecord::Base
has_secure_password
end
user = User.new(name: "david", password: "vr00m", password_confirmation: "vr00m")
user.authenticate("notright") # => false
user.authenticate("vr00m") # => user
user.password = "42password"
user.password_digest # => "$2a$04$iOfhwahFymCs5weB3BNH/uXkTG65HR.qpW.bNhEjFP3ftli3o5DQC"
password_digest
パスワードを暗号化したもの
DB上はこの値で保存される