我想在我的rails 3應用程序中實現exception_notifier和自定義異常處理 。當我只使用異常通知器時,一切正常。 在發展模式ExceptionNotifier和rescue_from
config.consider_all_requests_local = false
,並在我的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
在我的application.rb中
config.middleware.use ExceptionNotifier,
:email_prefix => "Error: ",
:sender_address => %{"notifier" <[email protected]>},
:exception_recipients => %w{ [email protected] }
唯一的問題似乎是,該選項不加載到request.env中。 我在一個額外的初始化程序中試過這個文件,我不知道還有什麼 - 它不工作。 目前我有一個非常醜陋的黑客,在發送郵件之前,我將request.env與 哈希合併。 任何想法?
你曾經找到解決這個問題的方法嗎?我也有,所以你可以提供的任何幫助非常感謝! – 2011-05-07 20:17:04
不,我不得不劫持request.env並手動設置它們 – Clint 2011-05-18 16:01:32
你能發表一個你如何做的例子嗎?再次感謝! – 2011-05-23 05:55:06