How can I rescue ActiveRecord::RecordNotFound in Activeadmin for all my resources?
I know in Rails I can put rescue_from(ActiveRecord::RecordNotFound)
in the ApplicationController, is there an equivalent way of doing this in ActiveAdmin?
How can I rescue ActiveRecord::RecordNotFound in Activeadmin for all my resources?
I know in Rails I can put rescue_from(ActiveRecord::RecordNotFound)
in the ApplicationController, is there an equivalent way of doing this in ActiveAdmin?
ActiveAdmin.register FooBar do
controller do
rescue_from ActiveRecord::RecordNotFound, with: :show_errors
def show_errors
# ...
end
end
end
EDIT: You can do this at one place for all resources:
require 'active_admin/base_controller'
ActiveAdmin::BaseController.class_eval do
rescue_from ActiveRecord::RecordNotFound, with: :show_errors
def show_errors
# ...
end
end