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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With