我已经通过运行以下命令安装了super_exception_notifier:
sudo gem install super_exception_notifier然后我尝试在我的项目中启用它(它已经可以发送邮件,因为它可以发送电子邮件用于其他目的),如下所示。在environment.rb上,我添加了
# Notification configuration
require 'exception_notifier'
ExceptionNotifier.configure_exception_notifier do |config|
config[:exception_recipients] = %w(info@isitsciencefiction.com)
config[:notify_error_codes] = %W( 404 405 500 503 )
end在我的application_controller.rb上,我有:
require 'exception_notifiable'
class ApplicationController < ActionController::Base
include ExceptionNotifiable我是不是遗漏了什么?因为无论我产生什么样的错误。无论是404,一个路由错误,在控制器或控制台中被零除,在开发或生产模式下,我没有收到任何电子邮件,也没有错误消息或任何东西。
有什么想法吗?
发布于 2009-11-18 03:34:59
巴勃罗
感谢您指出文档中的漏洞。我将设置一个空白的rails项目,然后清楚地列举步骤。我已经更新了自述文件,以响应您在github上创建的票证。
为了帮助你解决眼前的问题,这就是我如何设置它的(它对我来说也是有效的!:)并不是所有的部分都是它工作所必需的,但我并没有编辑它(太多),所以你可以看到我有什么:
我的environment.rb中有以下内容:
config.load_paths += %W( #{RAILS_ROOT}/app/middlewares #{RAILS_ROOT}/app/mixins #{RAILS_ROOT}/app/classes #{RAILS_ROOT}/app/mailers #{RAILS_ROOT}/app/observers )我在config/initializers/super_exception_notification.rb中有一个初始化器
#The constants ($) are set in the config/environments files.
ExceptionNotifier.configure_exception_notifier do |config|
config[:render_only] = false
config[:skip_local_notification] = false
config[:view_path] = 'app/views/errors'
config[:exception_recipients] = $ERROR_MAIL_RECIPIENTS
config[:send_email_error_codes] = $ERROR_STATUS_SEND_EMAIL
#config[:sender_address] = %("RINO #{(defined?(Rails) ? Rails.env : RAILS_ENV).humanize} Error" )
config[:sender_address] = "errors@swankywebdesign.com"
config[:email_prefix] = "[RINO #{(defined?(Rails) ? Rails.env : RAILS_ENV).capitalize} ERROR] "
end然后在我的application.rb中有这个:
include ExceptionNotifiable, CustomEnvironments
alias :rescue_action_locally :rescue_action_in_public if Environments.local_environments.include?(Rails.env)
self.error_layout = 'errors'
self.exception_notifiable_verbose = false
self.exception_notifiable_silent_exceptions = [MethodDisabled]然后在我的app/mixins目录中也有这个混入:
module CustomEnvironments
module Environments
def self.local_environments
%w( development test )
end
def self.deployed_environments
%w( production staging )
end
end
end还有一件事,这个插件并没有废除rails的标准,那就是公开的东西都是王牌。所以如果你有公共的404.html,它总是会被渲染到404。
发布于 2009-11-16 00:38:24
也许与此有关:http://github.com/pboling/exception_notification
只有在确定IP地址不在本地时,才会发出电子邮件通知。您可以指定某些地址始终是本地的,这样您就会得到一个详细的错误,而不是一般的错误页面。您可以在您的控制器(甚至是每个控制器)中执行此操作。
consider_local "64.72.18.143", "14.17.21.25"您还可以指定子网掩码,以便所有匹配的地址都被视为本地地址:
consider_local "64.72.18.143/24"地址"127.0.0.1“始终被视为本地地址。如果你想完全重置所有地址的列表(例如,如果你不想让"127.0.0.1“被认为是本地的),你可以简单地这样做,在你的控制器中的某个地方:
local_addresses.clearhttps://stackoverflow.com/questions/1738017
复制相似问题