Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kelhusseiny
Created April 20, 2012 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kelhusseiny/2426075 to your computer and use it in GitHub Desktop.
Save kelhusseiny/2426075 to your computer and use it in GitHub Desktop.
before_save :encrypt_password
after_save :clear_password
def encrypt_password
if password.present?
self.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