rails でエラーが出たときシステム管理者にエラー情報を送る
rails でエラーが出たとき、自分あてにエラー情報を送るようにしました。
アジャイル本 p.462 に載っているコードをそのまま使ったところうまく動きませんでした。
Googleで調べたら、Site5 Web Hosting Forumsに
Try using ::ActionController instead of ActionController. ActionController has weird problems being accessed from within a controller.
とあったので、その通り、
def rescue_action_in_public(exception) case exception when ActiveRecord::RecordNotFound, ::ActionController::UnknownAction render(:file => "#{RAILS_ROOT}/public/404.html", :status => "404 Not Found") else render(:file => "#{RAILS_ROOT}/public/500.html", :status => "500 Error") SystemNotifier.deliver_exception_notification( self, request, exception) end end
としたところ見事解決。Googleさまさまです。