Skip to content
This repository

Add comments about bcrypt-ruby gem to SecurePassword and add it to default Gemfile #2825

Merged
merged 2 commits into from over 2 years ago

2 participants

Guillermo Iguaran Aaron Patterson
Guillermo Iguaran

For details see the comments on 6779064

This can be merged safely in 3-1-stable and master. I will send changelog entry in another pull request (because is a change incompatible between branches)

Aaron Patterson tenderlove merged commit 8a9f4c6 into from September 03, 2011
Aaron Patterson tenderlove closed this September 03, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
6  activemodel/lib/active_model/secure_password.rb
@@ -10,6 +10,10 @@ module ClassMethods
10 10
       # a "password_confirmation" attribute) are automatically added.
11 11
       # You can add more validations by hand if need be.
12 12
       #
  13
+      # You need to add bcrypt-ruby (~> 3.0.0) to Gemfile to use has_secure_password:
  14
+      #
  15
+      #   gem 'bcrypt-ruby', '~> 3.0.0'
  16
+      #
13 17
       # Example using Active Record (which automatically includes ActiveModel::SecurePassword):
14 18
       #
15 19
       #   # Schema: User(name:string, password_digest:string)
@@ -28,6 +32,8 @@ module ClassMethods
28 32
       #   User.find_by_name("david").try(:authenticate, "notright")      # => nil
29 33
       #   User.find_by_name("david").try(:authenticate, "mUc3m00RsqyRe") # => user
30 34
       def has_secure_password
  35
+        # Load bcrypt-ruby only when has_secured_password is used to avoid make ActiveModel
  36
+        # (and by extension the entire framework) dependent on a binary library.
31 37
         gem 'bcrypt-ruby', '~> 3.0.0'
32 38
         require 'bcrypt'
33 39
 
3  railties/lib/rails/generators/rails/app/templates/Gemfile
@@ -10,6 +10,9 @@ source 'http://rubygems.org'
10 10
 <%= assets_gemfile_entry %>
11 11
 <%= javascript_gemfile_entry %>
12 12
 
  13
+# To use ActiveModel has_secure_password
  14
+# gem 'bcrypt-ruby', '~> 3.0.0'
  15
+
13 16
 # Use unicorn as the web server
14 17
 # gem 'unicorn'
15 18
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.