method

authenticate

Importance_1
Ruby on Rails latest stable (v7.1.3.2) - 0 notes - Class: InstanceMethodsOnActivation
authenticate(unencrypted_password) public

Returns self if the password is correct, otherwise false.

class User < ActiveRecord::Base
  has_secure_password validations: false
end

user = User.new(name: 'david', password: 'mUc3m00RsqyRe')
user.save
user.authenticate('notright')      # => false
user.authenticate('mUc3m00RsqyRe') # => user
Show source
Register or log in to add new notes.