我试图在我的rails 3应用程序中实现exception_notifier和自定义异常处理.当我只使用异常通知程序时,一切正常.在开发模式下
config.consider_all_requests_local = false
Run Code Online (Sandbox Code Playgroud)
和application_controller中的rescue_from:
unless Rails.application.config.consider_all_requests_local
rescue_from Exception, :with => :render_error
end
def render_error(exception)
ExceptionNotifier::Notifier.exception_notification(request.env, exception).deliver
end
Run Code Online (Sandbox Code Playgroud)
在我的application.rb中
config.middleware.use ExceptionNotifier,
:email_prefix => "Error: ",
:sender_address => %{"notifier" <notifier@wannagohome.com>},
:exception_recipients => %w{ myself@fail.com }
Run Code Online (Sandbox Code Playgroud)
唯一的问题似乎是,选项未加载到request.env中.我在一个额外的初始化程序中尝试了该文件,我不知道还有什么 - 它不起作用.目前我有一个非常丑陋的黑客,我在发送电子邮件之前将request.env与哈希合并..任何想法?