I need to have different versions of a gem for development and production, so I put the following in my gemfile.
group :development, :test do
gem 'rspec-rails', '2.11.0'
gem 'bcrypt-ruby', '3.1.2'
end
group :production do
gem 'rails_12factor'
gem 'bcrypt-ruby', '3.0.1'
end
but if i try to do bundle install
or even just rails console
I get the above error
I have tried
bundle install --without production
but I still get the error message. FYI: I need to do this because I am going thru the rails tutorial and there is a conflict that arises between windows, ruby 2.0.0 and bcrypt and Heroku so I am using bcrypt 3.1.2 on windows (with a modification to the active record gemfile) and bcrypt 3.0.1 on Heroku.
See this for more details: Issues using bcrypt 3.0.1 with ruby2.0 on Windows
I basically did what is mentioned in the first answer
EDIT
###################################################################
As the answer below points out, I really should be using the same version in both production and development (even tho I am just working thur a tutorial). What I ended up doing is monkey patching ActiveModel to use
gem 'bcrypt-ruby', '3.1.2'
rather than
gem 'bcrypt-ruby', '~> 3.0.0'
in secure_password.
I accomplished this by placing the following in lib/secure_password_using_3_1_2.rb
module ActiveModel
module SecurePassword
extend ActiveSupport::Concern
module ClassMethods
def has_secure_password
# 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'
gem 'bcrypt-ruby', '3.1.2'
require 'bcrypt'
attr_reader :password
validates_confirmation_of :password
validates_presence_of :password_digest
include InstanceMethodsOnActivation
if respond_to?(:attributes_protected_by_default)
def self.attributes_protected_by_default
super + ['password_digest']
end
end
end
end
end
end
and then adding the following to config/environment.rb
require File.expand_path('../../lib/secure_password_using_3_1_2.rb', __FILE__)