1

我的 Rails 版本是 3.0.4.rc1 和 ruby​​ 1.9.3p194

我面临着非常奇怪的问题。

在我的项目中,我得到了ERROR NoMethodError: undefined methodhas_key?对于 nil:NilClass in development.log file andInternal Server Errorhas_key?' for nil:NilClass浏览器中未定义的方法。

对于任何错误,如果它的无效语句、未定义的变量、引发、退出、错误的数据库名称.. 或其他任何错误,我只会收到上述错误消息。太令人沮丧了,我无法知道错误是什么或错误在哪里(行号和文件名)。

如果没有错误,它可以正常工作,但是当有任何错误(引发、退出或任何其他错误)时,它会显示相同的错误消息。即undefined methodhas_key?对于零:NilClass`

错误日志:

[2013-04-19 14:41:07] ERROR NoMethodError: undefined method `has_key?' for nil:NilClass
/home/shweta/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.4.rc1/lib/active_support/whiny_nil.rb:48:in `method_missing'
/home/shweta/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.2.5/lib/rack/runtime.rb:20:in `call'
/home/shweta/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.4.rc1/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/home/shweta/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.2.5/lib/rack/lock.rb:13:in `block in call'
<internal:prelude>:10:in `synchronize'
/home/shweta/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.2.5/lib/rack/lock.rb:13:in `call'
/home/shweta/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.4.rc1/lib/action_dispatch/middleware/static.rb:30:in `call'
/home/shweta/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.4.rc1/lib/rails/application.rb:168:in `call'
/home/shweta/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.4.rc1/lib/rails/application.rb:77:in `method_missing'
/home/shweta/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.4.rc1/lib/rails/rack/log_tailer.rb:14:in `call'
/home/shweta/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.2.5/lib/rack/content_length.rb:13:in `call'
/home/shweta/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.2.5/lib/rack/handler/webrick.rb:52:in `service'
/home/shweta/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/home/shweta/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/home/shweta/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

这表明当模型中存在语法错误时会出现此类问题,但我的模型文件很好。

请帮忙。

PS我在rails控制台中没有这个问题。

4

0 回答 0