after_filter for exceptions after_filter for exceptions ruby-on-rails ruby-on-rails

after_filter for exceptions


You can use an around_filter and catch the exceptions. Eg

# in a controlleraround_filter :catch_exceptionsdef catch_exceptions  yieldrescue ActiveRecord::RecordNotFound  permission_denied_response # gives a stock error pageend

You can add the around_filter in the application.rb controller class or in an individual controller's class.