Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change Standard error when is required bcrypt-ruby and fails

  • Loading branch information...
commit 7e07b7bb5da02f63d830eb70aae2835aa7d024ed 1 parent ecfdc84
@robertomiranda robertomiranda authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 activemodel/lib/active_model/secure_password.rb
View
9 activemodel/lib/active_model/secure_password.rb
@@ -43,8 +43,13 @@ def has_secure_password(options = {})
# Load bcrypt-ruby 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-ruby', '~> 3.0.0'
- require 'bcrypt'
+ begin
+ gem 'bcrypt-ruby', '~> 3.0.0'
+ require 'bcrypt'
+ rescue LoadError => e
+ $stderr.puts "You don't have bcrypt-ruby installed in your application. Please add it to your Gemfile and run bundle install"
+ raise e
+ end
attr_reader :password

2 comments on commit 7e07b7b

@jeremy
Owner

This masks the original exception backtrace and outputs the true error on stderr instead of in the exception message. Instead, this should rescue the gem activation error and raise a BcryptMissing error with this message.

Better yeah, get rid of the runtime gem activation entirely. If it's the app's responsibility to provide bcrypt, then simple require bcrypt here.

@jeremy
Owner

(Looks like the re-raise was fixed in a03ab8c)

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