提交 8d351eac 编写于 作者: J Joshua Peek

Extract Routing.controller_constraints

上级 53d7acdf
......@@ -276,6 +276,10 @@ module Helpers
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 @@ def connect(path, options = {})
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 @@ def match(*args)
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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册