You can use Rack middleware, for example:
module Rack class Snoop def initialize(app) @app = app end def call(env) status, headers, body = @app.call(env) case status when 200
You can use it by placing it in your config/application.rb or in one of config/environments/ENV.rb
config.middleware.insert_before(ActionDispatch::ShowExceptions, Rack::Snoop)
You will notice that I inserted it before ActionDispatch::ShowExceptions , because it will catch 500 errors caused by internal exceptions. If you want it elsewhere, you can peek into the middleware stack with rake middleware and put it wherever you want with insert_before or insert_after .
source share