The order of multiple rescue_from statements might be unexpected.

Take care when using rescue_from to rescue multiple errors.

The following will not work, because later rescue_from statements take precedence.

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

So, the first one redirect_to_home will never be called:

Now, how to make them work as expected? rescue the baisc exception last.

It’s easy, just reverse them. Make the general exception in the first order.

Good e.g.

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

FYI: