aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
diff options
context:
space:
mode:
author@schneems and @mattt <m@mattt.me>2012-07-01 20:00:10 -0700
committerschneems <richard.schneeman@gmail.com>2012-07-07 15:39:49 -0500
commitef91cddb48d1fa8d1a34e8e5ac68fe9eb56c160f (patch)
treeb78de2d49cf9c27cf0f56e50f54f8344d4d62380 /actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
parentfa714ec7dffd12b8508c756e6526eff5ae8e4202 (diff)
downloadrails-ef91cddb48d1fa8d1a34e8e5ac68fe9eb56c160f.tar.gz
rails-ef91cddb48d1fa8d1a34e8e5ac68fe9eb56c160f.tar.bz2
rails-ef91cddb48d1fa8d1a34e8e5ac68fe9eb56c160f.zip
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.
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/debug_exceptions.rb')
-rw-r--r--actionpack/lib/action_dispatch/middleware/debug_exceptions.rb12
1 files changed, 7 insertions, 5 deletions
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