diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index d80faf742361b9833194a29e42cb803aeaf23c54..f82c3c0d34677a9a9440cbfc764f892447a1c1ed 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -109,6 +109,7 @@ def initialize(set, ast, defaults, controller, default_action, modyoule, to, for @default_action = default_action @ast = ast @anchor = anchor + @via = via path_params = ast.find_all(&:symbol?).map(&:to_sym) @@ -140,9 +141,6 @@ def initialize(set, ast, defaults, controller, default_action, modyoule, to, for @defaults = formats[:defaults].merge(@defaults).merge(normalize_defaults(options)) @required_defaults = (split_options[:required_defaults] || []).map(&:first) - unless via == [:all] - @conditions[:request_method] = via.map { |m| m.to_s.dasherize.upcase } - end end def application @@ -164,8 +162,8 @@ def build_conditions(current_conditions, request_class) # :request_method represents the HTTP verb that matches this route. # # Here we munge values before they get sent on to rack-mount. - verbs = conditions[:request_method] || [] - unless verbs.empty? + unless @via == [:all] + verbs = @via.map { |m| m.to_s.dasherize.upcase } conditions[:request_method] = %r[^#{verbs.join('|')}$] end