This article was migrated from http://rails.office.drecom.jp/hibi/archive/20
アプリでどんなエラーでも拾うとき、rescue_act
ion_in_pub
licを使います。
http://wiki.rubyonrails.org/rails/pages/HowtoConfigureTheErrorPageForYourRailsApp
http://wiki.rubyonrails.org/rails/pages/DynamicErrorPagesWish
で、その際、UnkownActi
onなどを扱う場合は、フルパス?で指定しないといけないみたいです。
http://lists.rubyonrails.org/pipermail/rails/2006-February/016803.html
ActiveReco
rd::Record
NotFound => ::ActiveReco
rd::Record
NotFound
----------
----------
----------
----------
----------
def rescue_act
ion_in_pub
lic(exception)
case exception
when ::ActiveRe
cord::Reco
rdNotFound
, ::ActionCo
ntroller::
RoutingErr
or, ::ActionCo
ntroller::
UnknownAct
ion
render(:file => "#{RAILS_ROOT
}/public/40
4.html",
:status => "404 Not Found")
else
show_error
render(:file => "#{RAILS_ROOT
}/public/50
0.html",
:status => "500 Error")
end
end
http://rails.office.drecom.jp/hibi/archive/20This article was migrated from http://rails.office.drecom.jp/hibi/archive/20