0

我正在将 Rails 2.3.8 应用程序升级到 Rails 3.0.17 并在 mac osx Lion 环境中使用 RVM (Ruby 1.9.3)。(已经在使用捆绑器)。

我的应用程序运行正常,但是 rails 控制台给了我错误:(在任何数据库调用中)

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>'

请帮忙。

4

1 回答 1

0

在用户模型上更正回形针配置后,一切正常。感谢您的建议。

于 2012-10-11T22:10:41.370 回答