method

authenticate

Importance_1
v4.2.1 - Show latest stable - 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.