Ruby on rails UsersController中的Rails错误NoMethodError#显示错误
nil:NilClass的未定义方法“key?”Ruby on rails UsersController中的Rails错误NoMethodError#显示错误,ruby-on-rails,Ruby On Rails,nil:NilClass的未定义方法“key?” 这就是我在阅读M.Hartl的Rails教程时遇到的错误。另外,在保存我的用户\u controller.rb文件并刷新http://localhost:3000/users/1,我发现另一个错误是: Gem::LoadError in UsersController#show bcrypt-ruby is not part of the bundle. Add it to Gemfile. 然而,bcrypt ruby在我的GEM文件中,在
这就是我在阅读M.Hartl的Rails教程时遇到的错误。另外,在保存我的用户\u controller.rb文件并刷新http://localhost:3000/users/1
,我发现另一个错误是:
Gem::LoadError in UsersController#show
bcrypt-ruby is not part of the bundle. Add it to Gemfile.
然而,bcrypt ruby在我的GEM文件中,在我再次刷新之后,这个错误就消失了。只是有点奇怪
这是我的用户_controller.rb
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
end
def new
end
end
class UsersController
这是我的show.html.erb
<%= @user.name %>, <%= @user.email %>
,
非常感谢大家。也有同样的问题:(先尝试步骤3)
rails命令行>gem安装bcrypt-ruby
rails命令行>捆绑安装(不确定是否需要)
重新启动Rails服务器(您可以先尝试,这可能是唯一需要的步骤)
我也面临类似的困难。要解决这个问题,我所要做的就是重新启动rails服务器,它就工作了。我也遇到了同样的问题
在我重新启动服务器后,它工作了