0
我正在将Rails 2.3.8应用程序升级到Rails 3.0.17,并在mac osx Lion环境中使用RVM(Ruby 1.9.3)。 (已经在使用捆绑器)。Rails 3控制台引发错误
我的应用程序工作正常,但轨道控制台给我的错误:(在任何DB调用)
User.first
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
from /Users/franklin/rails_apps/myapp/app/models/user.rb:84:in `<class:User>'
from /Users/franklin/rails_apps/myapp/app/models/user.rb:1:in `<top (required)>'
from /Users/franklin/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.17/lib/active_support/dependencies.rb:458:in `load'
from /Users/franklin/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.17/lib/active_support/dependencies.rb:458:in `block in load_file'
from /Users/franklin/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.17/lib/active_support/dependencies.rb:597:in `new_constants_in'
from /Users/franklin/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.17/lib/active_support/dependencies.rb:457:in `load_file'
from /Users/franklin/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.17/lib/active_support/dependencies.rb:344:in `require_or_load'
from /Users/franklin/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.17/lib/active_support/dependencies.rb:491:in `load_missing_constant'
from /Users/franklin/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.17/lib/active_support/dependencies.rb:183:in `block in const_missing'
from /Users/franklin/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.17/lib/active_support/dependencies.rb:181:in `each'
from /Users/franklin/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.17/lib/active_support/dependencies.rb:181:in `const_missing'
from (irb):7
from /Users/franklin/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.17/lib/rails/commands/console.rb:44:in `start'
from /Users/franklin/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.17/lib/rails/commands/console.rb:8:in `start'
from /Users/franklin/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.17/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
请帮助。
堆栈跟踪清楚地表明您在user.rb中存在第84行的问题 – UncleGene
仅在少数模型调用中发生。 – Valadares
谢谢UncleGene。这次升级对我来说,我只是盲目的麻烦。 – Valadares