Permalink
Browse files

Fix exception rescueing in resource controller

  • Loading branch information...
jomz committed Feb 23, 2014
1 parent f2ca8ed commit dd2f1a56584708beb8578af65db3dd1f48ec7634
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 end
rescue_from ActiveRecord::RecordInvalid, :with => :invalid
rescue_from ActiveRecord::StaleObjectError, :with => :stale
rescue_from ActiveRecord::RecordNotFound, :with => :not_found
protected protected
def invalid
response_for :invalid
end
def rescue_action(exception) def stale
case exception response_for :stale
when ActiveRecord::RecordInvalid
response_for :invalid
when ActiveRecord::StaleObjectError
response_for :stale
when ActiveRecord::RecordNotFound
response_for :not_found
else
super
end
end end
def not_found
response_for :not_found
end
def model_class def model_class
self.class.model_class self.class.model_class
end end

0 comments on commit dd2f1a5

Please sign in to comment.