From ac0280c39dab272710c25d54810b21c10fff9c52 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 9 Apr 2010 21:48:35 -0700 Subject: Routes can be selectively namespaced by path or controller module --- actionpack/lib/action_dispatch/routing/mapper.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_dispatch/routing') 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 = {}) -- cgit v1.2.3