• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

This article was migrated from http://rails.office.drecom.jp/hibi/archive/20

アプリでどんなエラーでも拾うとき、rescue_action_in_publicを使います。
http://wiki.rubyonrails.org/rails/pages/HowtoConfigureTheErrorPageForYourRailsApp
http://wiki.rubyonrails.org/rails/pages/DynamicErrorPagesWish

で、その際、UnkownActionなどを扱う場合は、フルパス?で指定しないといけないみたいです。
http://lists.rubyonrails.org/pipermail/rails/2006-February/016803.html

ActiveRecord::RecordNotFound => ::ActiveRecord::RecordNotFound

--------------------------------------------------
def rescue_action_in_public(exception)
case exception
when ::ActiveRecord::RecordNotFound, ::ActionController::RoutingError, ::ActionController::UnknownAction
render(:file => "#{RAILS_ROOT}/public/404.html",
:status => "404 Not Found")
else
show_error
render(:file => "#{RAILS_ROOT}/public/500.html",
:status => "500 Error")
end
end http://rails.office.drecom.jp/hibi/archive/20

This article was migrated from http://rails.office.drecom.jp/hibi/archive/20

posted by Png satoko on Fri 4 Aug 2006 at 15:12

Comments:

or Preview
Social Bookmarks
  • Delicious
  • B_entry159
  • Clip_16_12_w
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ