1
我經歷教程 https://www.railstutorial.org/book/modeling_users並在第6章已經上市6.6,例如,在運行代碼的時候碰到一個問題,軌測試:模型錯誤RailsTutorials,第6章
rails test:models
在
控制檯我得到的錯誤
NameError: undefined local variable or method `models' for main:Object.
我有類似的結果試過這樣:
2.3.0 :010 > @user = User.new(name: "Example User", email:
"[email protected]")
=> #<User id: nil, name: "Example User", email: "[email protected]",
created_at: nil, updated_at: nil, password_digest: nil,
remember_digest: nil, admin: false, activation_digest: nil, activated:
false, activated_at: nil, reset_digest: nil, reset_sent_at: nil>
2.3.0 :011 > @user.name
=> "Example User"
2.3.0 :012 > @user.email
=> "[email protected]"
2.3.0 :013 > @user.valid?
=> true
2.3.0 :016 > NameError: undefined local variable or method `models' for
main:Object
問題/解決方案是什麼?
謝謝。這是問題和解決方案。 –