Skip to content
Browse files

Add comments about bcrypt-ruby gem to SecurePassword

  • Loading branch information...
1 parent af54fc5 commit 9b02f3f41f9be96bcc61222a8dcd197c1a2edf79 @guilleiguaran guilleiguaran committed
Showing with 6 additions and 0 deletions.
  1. +6 −0 activemodel/lib/active_model/secure_password.rb
View
6 activemodel/lib/active_model/secure_password.rb
@@ -10,6 +10,10 @@ module ClassMethods
# a "password_confirmation" attribute) are automatically added.
# You can add more validations by hand if need be.
#
+ # You need to add bcrypt-ruby (~> 3.0.0) to Gemfile to use has_secure_password:
+ #
+ # gem 'bcrypt-ruby', '~> 3.0.0'
+ #
# Example using Active Record (which automatically includes ActiveModel::SecurePassword):
#
# # Schema: User(name:string, password_digest:string)
@@ -28,6 +32,8 @@ module ClassMethods
# User.find_by_name("david").try(:authenticate, "notright") # => nil
# User.find_by_name("david").try(:authenticate, "mUc3m00RsqyRe") # => user
def has_secure_password
+ # Load bcrypt-ruby only when has_secured_password is used to avoid make ActiveModel
+ # (and by extension the entire framework) dependent on a binary library.
gem 'bcrypt-ruby', '~> 3.0.0'
require 'bcrypt'

0 comments on commit 9b02f3f

Please sign in to comment.
Something went wrong with that request. Please try again.