2009-11-15 38 views
1

我已经安装了super_exception_notifier运行:获取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([email protected]) 
    config[:notify_error_codes] = %W(404 405 500 503) 
end 

和我application_controller.rb我:

require 'exception_notifiable' 

class ApplicationController < ActionController::Base 
    include ExceptionNotifiable 

我缺少的东西?因为不管我产生什么错误。在开发或生产模式下,404或路由错误,在控制器或控制台中除零,我不会收到任何电子邮件,也不会收到任何错误消息或任何内容。

任何想法?

回答

0

巴勃罗,

感谢您指出文档中的孔。我将设置一个空栏项目,然后清楚地列举这些步骤。我已经更新了自述文件,以响应您在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) 

我在配置/初始化/ 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] = "[email protected]" 
    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] 

然后我也有这个混入我的应用程序/混入目录:

module CustomEnvironments 

    module Environments 
    def self.local_environments 
     %w(development test) 
    end 

    def self.deployed_environments 
     %w(production staging) 
    end 
    end 
end 

的另一件事,这个插件不取消钢轨标准这是公开的事情是王牌。所以如果你有404。在公共场合,它总是会呈现404的。

  • 彼得
0

也许它有事情做与此:当IP地址被确定为不当地将只发生 http://github.com/pboling/exception_notification

电子邮件通知。您可以指定某些地址始终为本地,以便您将获得详细的错误而不是通用错误页面。你可以在你的控制器(甚至是每个控制器)中执行此操作。

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.clear 
+0

嗯,我没试过,远程我在生产服务器;我希望控制台错误始终以本地方式发送。 – Pablo 2009-11-15 16:40:13