diff options
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 7 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 8 |
2 files changed, 10 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index c5e093dae5..c7f6ff620e 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -28,9 +28,16 @@ module ActionDispatch app = app.app end + # Unwrap any constraints so we can see what's inside for route generation. + # This allows the formatter to skip over any mounted applications or redirects + # that shouldn't be matched when using a url_for without a route name. + @dispatcher = app.is_a?(Routing::RouteSet::Dispatcher) + @app, @constraints, @request = app, constraints, request end + def dispatcher?; @dispatcher; end + def matches?(env) req = @request.new(env) diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index f36453020f..5839db87f9 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -703,12 +703,10 @@ module ActionDispatch end old_params = req.path_parameters req.path_parameters = old_params.merge params - dispatcher = route.app - if dispatcher.matches?(env) - dispatcher = dispatcher.app - end + app = route.app + if app.matches?(env) && app.dispatcher? + dispatcher = app.app - if dispatcher.is_a?(Dispatcher) if dispatcher.controller(params, false) dispatcher.prepare_params!(params) return params |