同時使用下列命令更新從鐵軌控制檯數據庫:我得到一個零對象引用的時候,我不希望它-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