简体   繁体   English

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

[英]uninitialized constant ActiveRecord from exception_notification gem

I Am using exception notifier like this in my rails 3.0.7- 我在Rails 3.0.7-中使用了这样的异常通知程序

gem 'exception_notification_rails3', :require => 'exception_notifier'

This application uses mongoid rather than ActiveRecord. 此应用程序使用蒙古包而不是ActiveRecord。 But when I try to open rails c, it give following error - 但是当我尝试打开导轨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

I tried googling over this, but couldn't find anything related. 我尝试使用Google搜索,但是找不到任何相关内容。 Thanks. 谢谢。

UPDATE - I just checked in /var/lib/gems/1.8/gems/exception_notification_rails3-1.2.0/lib/exception_notifier.rb file. 更新-我刚刚在/var/lib/gems/1.8/gems/exception_notification_rails3-1.2.0/lib/exception_notifier.rb文件中签入。 This file has code - 该文件具有代码-

exceptions << ActiveRecord::RecordNotFound if defined? ActiveRecord

So commented this, and checked. 因此对此发表了评论,并进行了检查。 Now the system works. 现在该系统正常工作。 So this means my active record is being declared somewhere. 因此,这意味着我的活动记录正在某处声明。 I reconfirmed this on console. 我在控制台上再次确认。

My application.rb file has this - 我的application.rb文件具有以下内容-

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

Now, what might be causing to include the ActiveRecord and then failing the Exception Notifier ? 现在,是什么原因导致包含ActiveRecord,然后使异常通知程序失败?

People, http://github.com/rails/exception_notification is no longer the official exception_notification repo. 亲爱的, http ://github.com/rails/exception_notification不再是官方的exception_notification存储库。 See the note on the home page. 请参阅主页上的注释。

The official repo lies now on http://github.com/smartinez87/exception_notification 官方仓库现在位于http://github.com/smartinez87/exception_notification

If you do gem install exception_notification it will pull the gem from there. 如果您执行gem install exception_notification ,它将从那里拉出gem。 This issue is already fixed there, if not please report the issue there. 该问题已在此处解决,如果尚未解决,请在此报告。

Thanks! 谢谢!

I found that some other gem was including the ActiveRecord as a dependency, and that was causing this to fail. 我发现其他一些宝石将ActiveRecord作为依赖项包括在内,这导致它失败。 I removed that gem and everything is fine now. 我删除了那个宝石,现在一切都很好。

Erik Hollensbe fixed this error in his personal fork of exception_notifier. Erik Hollensbe在他的exception_notifier 个人分叉修复了此错误 His solution worked perfectly for me under Rails 3.0.9 and Ruby 1.9.2p180. 在Rails 3.0.9和Ruby 1.9.2p180下,他的解决方案非常适合我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Rails中替代不推荐使用的exception_notification gem? - Alternative to deprecated exception_notification gem in Rails? 没有来自exception_notification插件的电子邮件警报 - no email alert from exception_notification plugin 带有 gem &#39;activerecord-session_store&#39; 的未初始化常量 ActiveRecord::SessionStore - uninitialized constant ActiveRecord::SessionStore with gem 'activerecord-session_store' exception_notification中的多个收件人 - multiple recipient in exception_notification 来自 Gem 的 Rails 中未初始化的常量 - Uninitialized constant in Rails from Gem Rails 4.1和exception_notification-rake gem导致未初始化的常量ExceptionNotification - Rails 4.1 and exception_notification-rake gem causing uninitialized constant ExceptionNotification 即使我已安装Rails,也无法找到exception_notification gem - Rails can't find exception_notification gem even though I have it installed 使用gem exception_notification时出现multi_json_1.3.6错误”,“〜&gt; 2.6.1” - multi_json_1.3.6 error while using gem exception_notification“, ”~> 2.6.1" 未初始化的常数ActiveRecord :: Transitions与rails 4.1和transitions gem - uninitialized constant ActiveRecord::Transitions with rails 4.1 and transitions gem yii等同于exception_notification? - What is the yii equivalent of exception_notification?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM