Reputation: 69
When I try to do this action I get the "LoadError (cannot load such file -- bcrypt)"
require 'bcrypt'
class PublicController < ApplicationController
def attempt_login
if params[:email].present? && params[:password].present?
found_user = User.where(:email => params[:email]).first
if found_user
authorized_user = found_user.authenticate(params[:password])
end
end
if authorized_user
render(:text =>'authorized')
redirect_to(:controller => 'private', :action => 'home')
else
flash[:notice] = "Invalid email or password"
render :new
end
end
end
User model:
class User < ApplicationRecord
has_secure_password
end
I have tried all of the following in the gemfile and I get the same error every time:
gem 'bcrypt', '~>3.1.11'
gem 'bcrypt', '~> 3.1', '>= 3.1.11'
gem 'bcrypt', platforms: :ruby
How can I get it to load the bcrypt gem? I'm using Windows 10.
Upvotes: 0
Views: 409
Reputation: 26
Try this:
bcrypt
from your Gemfile.gem uninstall bcrypt
.gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'
to your Gemfile.bundle install
.bundle install
.Source: https://github.com/codahale/bcrypt-ruby/issues/102#issuecomment-284118731
Upvotes: 1