Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails UsersController中的Rails错误NoMethodError#显示错误_Ruby On Rails - Fatal编程技术网

Ruby on rails UsersController中的Rails错误NoMethodError#显示错误

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文件中,在

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文件中,在我再次刷新之后,这个错误就消失了。只是有点奇怪

这是我的用户_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服务器,它就工作了。

    我也遇到了同样的问题

    在我重新启动服务器后,它工作了