module ActiveModel::SecurePassword::InstanceMethodsOnActivation

def password=(unencrypted_password)

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

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

new password is not empty.
Encrypts the password into the +password_digest+ attribute, only if the
def password=(unencrypted_password)
  if unencrypted_password.nil?
    self.password_digest = nil
  elsif !unencrypted_password.empty?
    @password = unencrypted_password
    cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost
    self.password_digest = BCrypt::Password.create(unencrypted_password, cost: cost)
  end
end