method

password=

rails latest stable - Class: ActiveModel::SecurePassword::InstanceMethodsOnActivation

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v5.2.3) is shown here.

password=(unencrypted_password)
public

Encrypts the password into the password_digest attribute, only if the new password is not empty.

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

user = User.new
user.password = nil
user.password_digest # => nil
user.password = 'mUc3m00RsqyRe'
user.password_digest # => "$2a$10$4LEA7r4YmNHtvlAvHhsYAeZmk/xeUVtMTYqwIvYY76EW5GUqDiP4."