Skip to content

Commit

Permalink
Merge pull request #14149 from tjschuck/bcrypt_gem_rename
Browse files Browse the repository at this point in the history
Bump version of bcrypt gem
  • Loading branch information
carlosantoniodasilva committed Feb 26, 2014
2 parents 1d298bd + 53f1ab5 commit 89b4b51
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion Gemfile
Expand Up @@ -8,11 +8,15 @@ gemspec
gem 'mocha', '~> 0.14', require: false

gem 'rack-cache', '~> 1.2'
gem 'bcrypt-ruby', '~> 3.1.2'
gem 'jquery-rails', '~> 3.1.0'
gem 'turbolinks'
gem 'coffee-rails', '~> 4.0.0'

# require: false so bcrypt is loaded only when has_secure_password is used.
# This is to avoid ActiveModel (and by extension the entire framework)
# being dependent on a binary library.
gem 'bcrypt', '~> 3.1.7', require: false

# This needs to be with require false to avoid
# it being automatically loaded by sprockets
gem 'uglifier', '>= 1.3.0', require: false
Expand Down
8 changes: 4 additions & 4 deletions activemodel/lib/active_model/secure_password.rb
Expand Up @@ -20,9 +20,9 @@ module ClassMethods
# value to the password_confirmation attribute and the validation
# will not be triggered.
#
# You need to add bcrypt-ruby (~> 3.1.2) to Gemfile to use #has_secure_password:
# You need to add bcrypt (~> 3.1.7) to Gemfile to use #has_secure_password:
#
# gem 'bcrypt-ruby', '~> 3.1.2'
# gem 'bcrypt', '~> 3.1.7'
#
# Example using Active Record (which automatically includes ActiveModel::SecurePassword):
#
Expand All @@ -42,13 +42,13 @@ module ClassMethods
# User.find_by(name: 'david').try(:authenticate, 'notright') # => false
# User.find_by(name: 'david').try(:authenticate, 'mUc3m00RsqyRe') # => user
def has_secure_password(options = {})
# Load bcrypt-ruby only when has_secure_password is used.
# Load bcrypt gem only when has_secure_password is used.
# This is to avoid ActiveModel (and by extension the entire framework)
# being dependent on a binary library.
begin
require 'bcrypt'
rescue LoadError
$stderr.puts "You don't have bcrypt-ruby installed in your application. Please add it to your Gemfile and run bundle install"
$stderr.puts "You don't have bcrypt installed in your application. Please add it to your Gemfile and run bundle install"
raise
end

Expand Down
2 changes: 1 addition & 1 deletion guides/code/getting_started/Gemfile
Expand Up @@ -27,7 +27,7 @@ gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/generators/rails/app/templates/Gemfile
Expand Up @@ -14,7 +14,7 @@ source 'https://rubygems.org'
<% end -%>

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'
Expand Down

0 comments on commit 89b4b51

Please sign in to comment.