From bf82820ce92d9e00376bb19818b97964dc6698ae Mon Sep 17 00:00:00 2001 From: Genadi Samokovarov Date: Wed, 29 Mar 2017 12:51:04 +0300 Subject: [PATCH] Keep the extension work in one common place This is the very first Railtie initializer. --- lib/web_console/extensions.rb | 4 +++- lib/web_console/railtie.rb | 7 +------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/web_console/extensions.rb b/lib/web_console/extensions.rb index d2b12ad7..c1976ed3 100644 --- a/lib/web_console/extensions.rb +++ b/lib/web_console/extensions.rb @@ -21,7 +21,7 @@ def console(binding = Bindex.current_bindings.second) end module WebConsole - module DebugExceptions + module DebugExceptionsExt def render_exception(request, exception) super(request, exception).tap do backtrace_cleaner = request.get_header('action_dispatch.backtrace_cleaner') @@ -40,3 +40,5 @@ def render_exception(request, exception) end end end + +ActionDispatch::DebugExceptions.prepend(WebConsole::DebugExceptionsExt) diff --git a/lib/web_console/railtie.rb b/lib/web_console/railtie.rb index d468d43f..77778507 100644 --- a/lib/web_console/railtie.rb +++ b/lib/web_console/railtie.rb @@ -40,6 +40,7 @@ class Railtie < ::Rails::Railtie if mount_point = config.web_console.mount_point Middleware.mount_point = mount_point.chomp('/') end + if root = Rails.application.config.relative_url_root Middleware.mount_point = File.join(root, Middleware.mount_point) end @@ -66,11 +67,5 @@ class Railtie < ::Rails::Railtie initializer 'i18n.load_path' do config.i18n.load_path.concat(Dir[File.expand_path('../locales/*.yml', __FILE__)]) end - - initializer 'web_console.patch_debug_exception_middleware' do |app| - app.config.after_initialize do - ActionDispatch::DebugExceptions.prepend DebugExceptions - end - end end end