我正在将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>'
请帮忙。
答案 0 :(得分:0)
在用户模型上更正Paperclip配置后,一切正常。谢谢你的建议。