我正在将现有应用程序升级到Rails 3.1,但在尝试查看页面时会出现以下错误。
在日志中我得到:
cache: [GET /assets/jquery.js?body=1] miss, store
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at Wed Sep 14 15:35:32 +0100 2011
Served asset /jquery.js - 200 OK (0ms)
[2011-09-14 15:35:32] ERROR 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.each
/Users/jamessmith/.rvm/gems/ruby-1.8.7-p352/gems/rack-1.3.2/lib/rack/handler/webrick.rb:71:in `service'
/Users/jamessmith/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/Users/jamessmith/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/Users/jamessmith/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/Users/jamessmith/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:162:in `start'
/Users/jamessmith/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/Users/jamessmith/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:95:in `start'
/Users/jamessmith/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:92:in `each'
/Users/jamessmith/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:92:in `start'
/Users/jamessmith/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:23:in `start'
/Users/jamessmith/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:82:in `start'
/Users/jamessmith/.rvm/gems/ruby-1.8.7-p352/gems/rack-1.3.2/lib/rack/handler/webrick.rb:13:in `run'
/Users/jamessmith/.rvm/gems/ruby-1.8.7-p352/gems/rack-1.3.2/lib/rack/server.rb:265:in `start'
/Users/jamessmith/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.0/lib/rails/commands/server.rb:70:in `start'
/Users/jamessmith/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.0/lib/rails/commands.rb:54
/Users/jamessmith/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.0/lib/rails/commands.rb:49:in `tap'
/Users/jamessmith/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.0/lib/rails/commands.rb:49
script/rails:6:in `require'
script/rails:6
我为每个CSS和JavaScript资产都搞定了。
当我尝试在浏览器窗口中查看资产时,我得到:
Internal Server Error
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.each
WEBrick/1.3.1 (Ruby/1.8.7/2011-06-30) at localhost:3000
答案 0 :(得分:1)
最后我不得不做一个rake rails:update
并更新它发现的每个文件冲突,确保检查旧文件和新文件之间的差异,然后适当地更新它们。