-
-
Save yosiyuki/0dda25bb3b71e9441308 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before_save :encrypt_password | |
after_save :clear_password | |
def encrypt_password | |
if password.present? | |
salt = BCrypt::Engine.generate_salt | |
self.encrypted_password= BCrypt::Engine.hash_secret(password, salt) | |
end | |
end | |
def clear_password | |
self.password = nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment