When I add has_secure_password to the model (inherited from ActiveRecord::Base), error stating that \"bcrypt-ruby is not part of the bundle\" occurs.
Here the log is
As the message says you need to add bcrypt-ruby to your Gemfile (at the root of the project).
Adding
gem "bcrypt-ruby"
and then running bundle install
should do the trick (this would fetch the gem if you hadn't already installed it).
You can specify specific versions to, eg
gem "bcrypt-ruby", "~> 3.0.1"
will get you the latest version that is >= to 3.0.1 but less than 3.1. You might do this if 3.0.1 has a bug fix you depend on and you're happy to get more bug fixes but you don't want major changes. There's loads more info on the bundler website.
In your Gemfile add a line
gem 'bcrypt-ruby'
and then from the command line
bundle install
Restart the server and reinstall bundle in correct order, that is:
bundle install, bundle update, bundle install
and then server restart.
If you already put the gem in the gem file and bundle installed and you are still getting an error then restart your server.
Something that came up for me that is not addressed here yet. I got this error after going to a new system on which I installed Ruby 2.0.x.
It turns out that even if I was using the new bcrypt 3.1.7 it didn't work for me until I ALSO had bcrypt-ruby 3.0.1 in the gemfile. I resisted that when I should have just taken the error at it's word.
gems:
bcrypt (3.1.7 ruby x86-mingw32)
bcrypt-ruby (3.0.1 x86-mingw32, 3.0.0)
gemfile:
gem 'bcrypt-ruby', '~> 3.0.1'
gem 'bcrypt', '~> 3.1.7'
Before adding both I tried all sorts of single version combinations.
I already had gem 'bcrypt-ruby', '~> 3.0.0'
in Gemfile, and had already ran the command bundle
, and yet I still got that message. The problem was that I forgot to restart the server:
touch tmp/restart.txt