aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorJoao Carlos <mail@joao-carlos.com>2010-01-09 03:51:31 +0200
committerJosé Valim <jose.valim@gmail.com>2010-01-10 12:49:31 +0100
commit36969c6ecd69fc285bf0267805152319a4b71ceb (patch)
tree9fcfddd7a340bc6e8fc44b00fefedafd8a774417 /actionpack/lib/action_dispatch
parentd2c4a93c6966cb06d6029f9f4dbe5f71a52a02db (diff)
downloadrails-36969c6ecd69fc285bf0267805152319a4b71ceb.tar.gz
rails-36969c6ecd69fc285bf0267805152319a4b71ceb.tar.bz2
rails-36969c6ecd69fc285bf0267805152319a4b71ceb.zip
Fixes namespaced routes [#3673 status:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/lib/action_dispatch')
-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 = {})