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.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 925e91f081..bf707f354a 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -323,8 +323,21 @@ module ActionDispatch
scope(controller.to_sym) { yield }
end
- def namespace(path)
- scope(path.to_s, :name_prefix => path.to_s, :controller_namespace => path.to_s) { yield }
+ def namespace(path_or_options)
+ options =
+ case path_or_options
+ when String, Symbol
+ path = path_or_options.to_s
+ { :path => path,
+ :name_prefix => path,
+ :controller_namespace => path }
+ when Hash
+ { :path => path_or_options[:path],
+ :controller_namespace => path_or_options[:controller] }
+ else
+ raise ArgumentError, "Unknown namespace: #{path_or_options.inspect}"
+ end
+ scope(options) { yield }
end
def constraints(constraints = {})