aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/mapper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/mapper.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 3e577c7f99..00659c8bd4 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -258,10 +258,17 @@ module ActionDispatch
else
name_prefix_set = false
end
+
+ if namespace = options.delete(:namespace)
+ namespace_set = true
+ namespace, @scope[:namespace] = @scope[:namespace], namespace
+ else
+ namespace_set = false
+ end
if controller = options.delete(:controller)
controller_set = true
- controller, @scope[:controller] = @scope[:controller], controller
+ controller, @scope[:controller] = @scope[:controller], @scope[:namespace] ? "#{@scope[:namespace]}/#{controller}" : controller
else
controller_set = false
end
@@ -281,6 +288,7 @@ module ActionDispatch
ensure
@scope[:path] = path if path_set
@scope[:name_prefix] = name_prefix if name_prefix_set
+ @scope[:namespace] = namespace if namespace_set
@scope[:controller] = controller if controller_set
@scope[:options] = options
@scope[:blocks] = blocks
@@ -292,7 +300,7 @@ module ActionDispatch
end
def namespace(path)
- scope("/#{path}", :name_prefix => path.to_s) { yield }
+ scope("/#{path}", :name_prefix => path.to_s, :namespace => path.to_s) { yield }
end
def constraints(constraints = {})