2006/10/30
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さまさまです。
この記事にリンク
- iPhoneアプリ「かなぶん」がそこそこ売れるようになった訳 その2
- 鳥頭のための Annotate Models 後継 gem
- DateHelperJa プラグインを Rails 2.3.4 上で動作確認



