Permalink
Browse files

Fix exception rescueing in resource controller

  • Loading branch information...
1 parent f2ca8ed commit dd2f1a56584708beb8578af65db3dd1f48ec7634 @jomz jomz committed Feb 23, 2014
Showing with 13 additions and 11 deletions.
  1. +13 −11 app/controllers/radiant/admin/resource_controller.rb
@@ -126,21 +126,23 @@ def pagination_parameters
}
end
+ rescue_from ActiveRecord::RecordInvalid, :with => :invalid
+ rescue_from ActiveRecord::StaleObjectError, :with => :stale
+ rescue_from ActiveRecord::RecordNotFound, :with => :not_found
protected
+
+ def invalid
+ response_for :invalid
+ end
- def rescue_action(exception)
- case exception
- when ActiveRecord::RecordInvalid
- response_for :invalid
- when ActiveRecord::StaleObjectError
- response_for :stale
- when ActiveRecord::RecordNotFound
- response_for :not_found
- else
- super
- end
+ def stale
+ response_for :stale
end
+ def not_found
+ response_for :not_found
+ end
+
def model_class
self.class.model_class
end

0 comments on commit dd2f1a5

Please sign in to comment.