diff options
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/routing.rb | 4 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/deprecated_mapper.rb | 3 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 2 |
3 files changed, 7 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing.rb b/actionpack/lib/action_dispatch/routing.rb index 751dbb88d3..e0857fb2b1 100644 --- a/actionpack/lib/action_dispatch/routing.rb +++ b/actionpack/lib/action_dispatch/routing.rb @@ -276,6 +276,10 @@ module ActionDispatch end class << self + def controller_constraints + Regexp.union(*possible_controllers.collect { |n| Regexp.escape(n) }) + end + # Expects an array of controller names as the first argument. # Executes the passed block with only the named controllers named available. # This method is used in internal Rails testing. diff --git a/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb b/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb index 0564ba9797..dd76391870 100644 --- a/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb +++ b/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb @@ -113,8 +113,7 @@ module ActionDispatch end end - possible_names = Routing.possible_controllers.collect { |n| Regexp.escape(n) } - requirements[:controller] ||= Regexp.union(*possible_names) + requirements[:controller] ||= Routing.controller_constraints if defaults[:controller] defaults[:action] ||= 'index' diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 6e112c9b54..cfe7425a61 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -282,6 +282,8 @@ module ActionDispatch constraints.reject! { |k, v| segment_keys.include?(k.to_s) } conditions.merge!(constraints) + requirements[:controller] ||= Routing.controller_constraints + if via = options[:via] via = Array(via).map { |m| m.to_s.upcase } conditions[:request_method] = Regexp.union(*via) |