Tuesday, 15 May 2012

ruby on rails - bcrypt LoadError: Cannot load such file -



ruby on rails - bcrypt LoadError: Cannot load such file -

i'm trying set login function rails app, i'm getting bcrypt error message when press login button:

loaderror in sessionscontroller#create cannot load such file -- bcrypt

is else getting error? have latest version of bcrypt , i'm next tutorial told me do.

user model: set asterisks around line error allegedly is.

class user < activerecord::base ****has_secure_password**** end

sessions controller:

class sessionscontroller < applicationcontroller def new end def create user = user.find_by(id: params[session][:id]) if user && user.authenticate(params[:session][:password]) log_in user redirect_to root_path else flash.now[:danger] = 'invalid' render 'new' end end def destroy end end

applicationcontroller:

class applicationcontroller < actioncontroller::base protect_from_forgery with: :exception include sessionshelper end

sessionshelper:

module sessionshelper def log_in(user) session[:user_id] = user.id end end

gemfile:

gem 'bcrypt', '~> 3.1.7'

sessions/new view:

<div id= "admin-sign-in"> <%= form_for(:session, url: login_path) |f| %> <%= f.label :id %> <%= f.text_field :id %> <%= f.label :password %> <%= f.password_field :password %> <%= f.submit "log in", class: "btn btn-primary" %> <% end %> </div>

if have run: bundle install install bcrypt, restart rails server. worked me.

ruby-on-rails ruby ruby-on-rails-4 load bcrypt

No comments:

Post a Comment