1

I am a Rails beginner. When i am trying to use gem bcrypt, i see an error on my screen "cannot load such file -- bcrypt" control stuck at 'has_secure_password' line of Model.

Server logs

LoadError (cannot load such file -- bcrypt):

app/models/user.rb:3:in `<class:User>'
app/models/user.rb:1:in `<top (required)>'
app/controllers/users_controller.rb:4:in `new'
Started GET "/signup" for 127.0.0.1 at 2018-02-18 15:03:08 +0530
Processing by UsersController#new as HTML
You don't have bcrypt installed in your application. Please add it to your Gemfile and run bundle install
Completed 500 Internal Server Error in 22ms (ActiveRecord: 0.0ms)



LoadError (cannot load such file -- bcrypt):

app/models/user.rb:3:in `<class:User>'
app/models/user.rb:1:in `<top (required)>'
app/controllers/users_controller.rb:4:in `new'

Gem file

#gem 'bcrypt-ruby', '3.1.5', :require => 'bcrypt'
gem 'bcrypt', '~> 3.1.7'

I've used both the above gems executing one at time. Even after checking out many blogs and sites, i could not find a solution.

I could bring up my rails server with no issues, but could not open my View in the browser.

Can someone help.

1 Answers1

0

If you use windows then follow the steps

Run this for uninstalling

gem uninstall bcrypt
gem uninstall bcrypt-ruby

Then install using

gem install bcrypt --platform=ruby

if you using devise then not need to add gem 'bcrypt', '~> 3.1.7' to you Gemfile because it included devise gem

Otherwise, add this gem to your gem file not need to run bundle installing or update

After all of this don't forget to restart your server.

Hope it helps

fool-dev
  • 7,671
  • 9
  • 40
  • 54