同时使用下列命令更新从铁轨控制台数据库:我得到一个零对象引用的时候,我不希望它-ROR
user=User.first
User Load (0.4ms) SELECT "users".* FROM "users" LIMIT 1
=> nil
,然后当我使用更新
user.update_attributes(:email => "[email protected]", :password => "foobar", :password_confirmation => "foobar")`
我得到此错误:
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.update_attributes
我想从mhartl教程中学习ROR,这与本教程有关。我发现在网站上已经回答了类似的问题,但无法做出任何表示。所以张贴我的具体错误在这里。
因此,您显然在数据库中没有用户。 – 2012-01-17 07:04:42