From ef91cddb48d1fa8d1a34e8e5ac68fe9eb56c160f Mon Sep 17 00:00:00 2001 From: "@schneems and @mattt" Date: Sun, 1 Jul 2012 20:00:10 -0700 Subject: move route_inspector to actionpack this is so we can show route output in the development when we get a routing error. Railties can use features of ActionDispatch, but ActionDispatch should not depend on Railties. --- .../lib/action_dispatch/middleware/debug_exceptions.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'actionpack/lib/action_dispatch/middleware') diff --git a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb index 467437b512..af3e6b3557 100644 --- a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb @@ -1,6 +1,6 @@ require 'action_dispatch/http/request' require 'action_dispatch/middleware/exception_wrapper' -require 'rails/application/route_inspector' +require 'action_dispatch/routing/inspector' module ActionDispatch @@ -9,8 +9,9 @@ module ActionDispatch class DebugExceptions RESCUES_TEMPLATE_PATH = File.join(File.dirname(__FILE__), 'templates') - def initialize(app) - @app = app + def initialize(app, routes_app = nil) + @app = app + @routes_app = routes_app end def call(env) @@ -84,9 +85,10 @@ module ActionDispatch private def formatted_routes(exception) + return false unless @routes_app.respond_to?(:routes) if exception.is_a?(ActionController::RoutingError) || exception.is_a?(ActionView::Template::Error) - inspector = Rails::Application::RouteInspector.new - inspector.format(Rails.application.routes.routes).join("\n") + inspector = ActionDispatch::Routing::RouteInspector.new + inspector.format(@routes_app.routes.routes).join("\n") end end end -- cgit v1.2.3