来自exception_notification gem的未初始化的常量ActiveRecord

时间:2011-06-20 08:57:50

标签: ruby-on-rails ruby-on-rails-3 activerecord mongoid

我在rails 3.0.7-

中使用了这样的异常通知程序
gem 'exception_notification_rails3', :require => 'exception_notifier'

此应用程序使用mongoid而不是ActiveRecord。但是当我尝试打开rails c时,会出现以下错误 -

Could not load SystemTimer >= v1.2.0. Falling back to timeout.rb. SystemTimer is STRONGLY recommended for timeouts in Ruby 1.8.7. See http://ph7spot.com/blog/system-timer-1-2-release for details.
/var/lib/gems/1.8/gems/exception_notification_rails3-1.2.0/lib/exception_notifier.rb:8:in `default_ignore_exceptions': uninitialized constant ActiveRecord::RecordNotFound (NameError)
from /var/lib/gems/1.8/gems/exception_notification_rails3-1.2.0/lib/exception_notifier.rb:7:in `tap'
from /var/lib/gems/1.8/gems/exception_notification_rails3-1.2.0/lib/exception_notifier.rb:7:in `default_ignore_exceptions'
from /var/lib/gems/1.8/gems/exception_notification_rails3-1.2.0/lib/exception_notifier.rb:30:in `initialize'
from /var/lib/gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:33:in `new'
from /var/lib/gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:33:in `build'
from /var/lib/gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:79:in `build'
from /var/lib/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:209:in `inject'
from /var/lib/gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:79:in `each'
from /var/lib/gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:79:in `inject'
from /var/lib/gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/stack.rb:79:in `build'
from /var/lib/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:162:in `build_middleware_stack'
from /var/lib/gems/1.8/gems/railties-3.0.7/lib/rails/application/finisher.rb:35
from /var/lib/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `instance_exec'
from /var/lib/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `run'
from /var/lib/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:50:in `run_initializers'
from /var/lib/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `each'
from /var/lib/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `run_initializers'
from /var/lib/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:134:in `initialize!'
from /var/lib/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:in `send'
from /var/lib/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
from /home/rtdp/workspace/bids/config/environment.rb:5
from /var/lib/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:103:in `require_environment!'
from /var/lib/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:22
from script/rails:6:in `require'
from script/rails:6

我尝试使用谷歌搜索,但找不到任何相关内容。 感谢。

更新 - 我刚刚检查了/var/lib/gems/1.8/gems/exception_notification_rails3-1.2.0/lib/exception_notifier.rb文件。该文件包含代码 -

exceptions << ActiveRecord::RecordNotFound if defined? ActiveRecord

对此进行了评论,并进行了检查。现在系统工作了。所以这意味着我的活动记录正在某处宣布。我在控制台上重新确认了这一点。

我的application.rb文件有这个 -

require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"

现在,可能导致包含ActiveRecord然后使异常通知程序失败的原因是什么?

3 个答案:

答案 0 :(得分:3)

人们,http://github.com/rails/exception_notification不再是官方的例外通知回购。请参阅主页上的注释。

官方回购现在在http://github.com/smartinez87/exception_notification

如果你做gem install exception_notification它会从那里拉出宝石。 这个问题已经解决,如果没有,请在那里报告问题。

谢谢!

答案 1 :(得分:0)

我发现其他一些gem包含ActiveRecord作为依赖项,这导致它失败。我删除了那颗宝石,现在一切都很好。

答案 2 :(得分:0)

Erik Hollensbe fixed this error在他的personal fork exception_notifier中。他的解决方案在Rails 3.0.9和Ruby 1.9.2p180下完美适合我。