diff options
author | Brennan Dunn <me@brennandunn.com> | 2008-08-28 07:53:29 -0400 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-08-28 12:29:49 -0700 |
commit | 9cc8c0a0a18163fb6ae0f66b2513c902d19459dc (patch) | |
tree | 1731a3f436612031aec1b812fe1e2fb5b4d7da44 /actionpack/lib/action_controller | |
parent | 7bdd5b768e51f74fa437d1cc8f3c36643364c4fe (diff) | |
download | rails-9cc8c0a0a18163fb6ae0f66b2513c902d19459dc.tar.gz rails-9cc8c0a0a18163fb6ae0f66b2513c902d19459dc.tar.bz2 rails-9cc8c0a0a18163fb6ae0f66b2513c902d19459dc.zip |
Routes may be restricted to lists of HTTP methods instead of a single method or :any.
[#407 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/routing/builder.rb | 12 | ||||
-rw-r--r-- | actionpack/lib/action_controller/routing/route.rb | 2 |
2 files changed, 8 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/routing/builder.rb b/actionpack/lib/action_controller/routing/builder.rb index 03427e41de..5704d9d01a 100644 --- a/actionpack/lib/action_controller/routing/builder.rb +++ b/actionpack/lib/action_controller/routing/builder.rb @@ -187,12 +187,14 @@ module ActionController private def validate_route_conditions(conditions) if method = conditions[:method] - if method == :head - raise ArgumentError, "HTTP method HEAD is invalid in route conditions. Rails processes HEAD requests the same as GETs, returning just the response headers" - end + [method].flatten.each do |m| + if m == :head + raise ArgumentError, "HTTP method HEAD is invalid in route conditions. Rails processes HEAD requests the same as GETs, returning just the response headers" + end - unless HTTP_METHODS.include?(method.to_sym) - raise ArgumentError, "Invalid HTTP method specified in route conditions: #{conditions.inspect}" + unless HTTP_METHODS.include?(m.to_sym) + raise ArgumentError, "Invalid HTTP method specified in route conditions: #{conditions.inspect}" + end end end end diff --git a/actionpack/lib/action_controller/routing/route.rb b/actionpack/lib/action_controller/routing/route.rb index 2106ac09e0..3b2cb28545 100644 --- a/actionpack/lib/action_controller/routing/route.rb +++ b/actionpack/lib/action_controller/routing/route.rb @@ -201,7 +201,7 @@ module ActionController # recognition, not generation. def recognition_conditions result = ["(match = #{Regexp.new(recognition_pattern).inspect}.match(path))"] - result << "conditions[:method] === env[:method]" if conditions[:method] + result << "[conditions[:method]].flatten.include?(env[:method])" if conditions[:method] result end |