aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-05-30 11:12:01 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-06-03 11:33:51 -0700
commit6a3cbaca2e460fc490ffcb168d3bc7c4f26f3abc (patch)
treeaf540a837305928b20aa7ef309cfb74ed3a75e43 /actionpack/lib
parent16e210745cc66de971cfb422b27c6f39b9201680 (diff)
downloadrails-6a3cbaca2e460fc490ffcb168d3bc7c4f26f3abc.tar.gz
rails-6a3cbaca2e460fc490ffcb168d3bc7c4f26f3abc.tar.bz2
rails-6a3cbaca2e460fc490ffcb168d3bc7c4f26f3abc.zip
always pull out a via variable and simplify logic
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb27
1 files changed, 15 insertions, 12 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index fc658482dc..1f910e8cb6 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -213,19 +213,22 @@ module ActionDispatch
end
@conditions[:required_defaults] = required_defaults
- via_all = options.delete(:via) if options[:via] == :all
-
- if !via_all && options[:via].blank?
- msg = "You should not use the `match` method in your router without specifying an HTTP method.\n" \
- "If you want to expose your action to both GET and POST, add `via: [:get, :post]` option.\n" \
- "If you want to expose your action to GET, use `get` in the router:\n" \
- " Instead of: match \"controller#action\"\n" \
- " Do: get \"controller#action\""
- raise ArgumentError, msg
- end
+ via = options[:via]
+
+ if via == :all
+ options.delete(:via)
+ else
+ via = Array(via).compact
+ if via.empty?
+ msg = "You should not use the `match` method in your router without specifying an HTTP method.\n" \
+ "If you want to expose your action to both GET and POST, add `via: [:get, :post]` option.\n" \
+ "If you want to expose your action to GET, use `get` in the router:\n" \
+ " Instead of: match \"controller#action\"\n" \
+ " Do: get \"controller#action\""
+ raise ArgumentError, msg
+ end
- if via = options[:via]
- @conditions[:request_method] = Array(via).map { |m| m.to_s.dasherize.upcase }
+ @conditions[:request_method] = via.map { |m| m.to_s.dasherize.upcase }
end
end