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.
Had the same problem: (try step 3 first)
I faced similar difficulties. To solve it, all I had to do was restart the rails server and it worked.
I had the same problem
it worked after i restarted the server
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.