Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Error NoMethodError in UsersController#show error

undefined method 'key?' for nil:NilClass

This is the error I am getting while going through M. Hartl's Rails Tutorial. Also, after saving my user_controller.rb file and refreshing http://localhost:3000/users/1, I get another error that is:

Gem::LoadError in UsersController#show

bcrypt-ruby is not part of the bundle. Add it to Gemfile.

bcrypt-ruby is in my gemfile however, and after I refresh again this error is gone. Its just a bit weird.

Here is my user_controller.rb

class UsersController < ApplicationController

  def show
    @user = User.find(params[:id])
  end

  def new
  end
end

and here is my show.html.erb

<%= @user.name %>, <%= @user.email %> 

Thank you all very much.

like image 511
ezis Avatar asked Aug 02 '26 05:08

ezis


1 Answers

Had the same problem: (try step 3 first)

  1. rails command line> gem install bcrypt-ruby
  2. rails command line> bundle install (not sure this was needed)
  3. Restart the Rails Server (you could try this first -this may have been the only step needed)
like image 136
Robert Karlsson Avatar answered Aug 04 '26 21:08

Robert Karlsson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!