Read more

Order of multiple "rescue_from" statements might be unexpected

Tobias Kraze
June 27, 2012Software engineer at makandra GmbH

Take care when using rescue_from to rescue multiple errors.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

The following will not work, because later rescue_from statements take precedence and so the first one will never be called:

rescue_from AccessDenied, :with => :redirect_to_home
rescue_from Exception, :with => :render_500

Simply reverse them.

Posted by Tobias Kraze to makandra dev (2012-06-27 13:38)