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 book lover

Growing Rails Applications in Practice

Check out our e-book. Learn to structure large Ruby on Rails codebases with the tools you already know and love.

  • Introduce design conventions for controllers and user-facing models
  • Create a system for growth
  • Build applications to last
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)