mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Extract Routing.controller_constraints
This commit is contained in:
parent
53d7acdf4f
commit
8d351eac07
3 changed files with 7 additions and 2 deletions
|
@ -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.
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue