aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2010-04-09 21:48:35 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2010-04-09 21:48:35 -0700
commitac0280c39dab272710c25d54810b21c10fff9c52 (patch)
tree8f5403bdb52126bf79330a972c9a8a0fbe095a60 /actionpack/lib
parente77a0311e59048f9f11cfda0ce976a93f4629122 (diff)
downloadrails-ac0280c39dab272710c25d54810b21c10fff9c52.tar.gz
rails-ac0280c39dab272710c25d54810b21c10fff9c52.tar.bz2
rails-ac0280c39dab272710c25d54810b21c10fff9c52.zip
Routes can be selectively namespaced by path or controller module
Diffstat (limited to 'actionpack/lib')
-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 = {})