4

ActiveAdmin and the better_errors gem don't play nice. Any rendering error makes the Rails server seize up and eat all my cpu, requiring a kill -9 to get out of the death-spin and pick the pieces up. Is there a way to conditionally use better_errors in one part of my app without using it in the part where ActiveAdmin lives?

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
ivan
  • 6,032
  • 9
  • 42
  • 65

1 Answers1

0

In my example I prepare lib/middleware/better_errors_patch.rb.

if Rails.env.development? || Rails.env.test?
  require 'better_errors'

  module BetterErrors
    class Middleware
      def call(env)
        if allow_ip?(env) && !env['PATH_INFO'].match(%r{\/admin\/})
          better_errors_call env
        else
          @app.call env
        end
      end
    end
  end
end

I resolve it by this monkey_patch. First, set gem 'better_errors', require: false in your Gemfile.Then you add require './lib/middleware/ex_better_errors' in application.rb scope. It works for me.

tkowt
  • 185
  • 1
  • 13