<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -307,13 +307,13 @@ module ActionController
     #     map.resources :tags, :path_prefix =&gt; '/toys/:toy_id',   :name_prefix =&gt; 'toy_'
     #
     # You may also use &lt;tt&gt;:name_prefix&lt;/tt&gt; to override the generic named routes in a nested resource:
-    # 
+    #
     #   map.resources :articles do |article|
     #     article.resources :comments, :name_prefix =&gt; nil
-    #   end 
-    # 
+    #   end
+    #
     # This will yield named resources like so:
-    # 
+    #
     #   comments_url(@article)
     #   comment_url(@article, @comment)
     #
@@ -559,6 +559,7 @@ module ActionController
       def action_options_for(action, resource, method = nil)
         default_options = { :action =&gt; action.to_s }
         require_id = !resource.kind_of?(SingletonResource)
+
         case default_options[:action]
           when &quot;index&quot;, &quot;new&quot;; default_options.merge(add_conditions_for(resource.conditions, method || :get)).merge(resource.requirements)
           when &quot;create&quot;;       default_options.merge(add_conditions_for(resource.conditions, method || :post)).merge(resource.requirements)</diff>
      <filename>actionpack/lib/action_controller/resources.rb</filename>
    </modified>
    <modified>
      <diff>@@ -76,6 +76,8 @@ module ActionController
         defaults     = (options.delete(:defaults)     || {}).dup
         conditions   = (options.delete(:conditions)   || {}).dup
 
+        validate_route_conditions(conditions)
+
         path_keys = segments.collect { |segment| segment.key if segment.respond_to?(:key) }.compact
         options.each do |key, value|
           hash = (path_keys.include?(key) &amp;&amp; ! value.is_a?(Regexp)) ? defaults : requirements
@@ -198,6 +200,19 @@ module ActionController
 
         route
       end
+
+      private
+        def validate_route_conditions(conditions)
+          if method = conditions[:method]
+            if method == :head
+              raise ArgumentError, &quot;HTTP method HEAD is invalid in route conditions. Rails processes HEAD requests the same as GETs, returning just the response headers&quot;
+            end
+
+            unless HTTP_METHODS.include?(method.to_sym)
+              raise ArgumentError, &quot;Invalid HTTP method specified in route conditions: #{conditions.inspect}&quot;
+            end
+          end
+        end
     end
   end
 end</diff>
      <filename>actionpack/lib/action_controller/routing/builder.rb</filename>
    </modified>
    <modified>
      <diff>@@ -516,6 +516,26 @@ class ResourcesTest &lt; Test::Unit::TestCase
     end
   end
 
+  def test_should_not_allow_invalid_head_method_for_member_routes
+    with_routing do |set|
+      set.draw do |map|
+        assert_raises(ArgumentError) do
+          map.resources :messages, :member =&gt; {:something =&gt; :head}
+        end
+      end
+    end
+  end
+
+  def test_should_not_allow_invalid_http_methods_for_member_routes
+    with_routing do |set|
+      set.draw do |map|
+        assert_raises(ArgumentError) do
+          map.resources :messages, :member =&gt; {:something =&gt; :invalid}
+        end
+      end
+    end
+  end
+
   def test_resource_action_separator
     with_routing do |set|
       set.draw do |map|</diff>
      <filename>actionpack/test/controller/resources_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1801,6 +1801,22 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do
       end
     end
 
+    def test_route_requirements_with_invalid_http_method_is_invalid
+      assert_raises ArgumentError do
+        set.draw do |map|
+          map.connect 'valid/route', :controller =&gt; 'pages', :action =&gt; 'show', :conditions =&gt; {:method =&gt; :invalid}
+        end
+      end
+    end
+
+    def test_route_requirements_with_head_method_condition_is_invalid
+      assert_raises ArgumentError do
+        set.draw do |map|
+          map.connect 'valid/route', :controller =&gt; 'pages', :action =&gt; 'show', :conditions =&gt; {:method =&gt; :head}
+        end
+      end
+    end
+
     def test_non_path_route_requirements_match_all
       set.draw do |map|
         map.connect 'page/37s', :controller =&gt; 'pages', :action =&gt; 'show', :name =&gt; /(jamis|david)/</diff>
      <filename>actionpack/test/controller/routing_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c3d1fda555c4bd5f8821d830c685ae5d0e7e52d0</id>
    </parent>
  </parents>
  <author>
    <name>Tom Ward</name>
    <email>tom@popdog.net</email>
  </author>
  <url>http://github.com/rails/rails/commit/d39485078ec56e25a96e97d44b53498d8a1c7426</url>
  <id>d39485078ec56e25a96e97d44b53498d8a1c7426</id>
  <committed-date>2008-07-18T18:19:03-07:00</committed-date>
  <authored-date>2008-07-18T18:19:03-07:00</authored-date>
  <message>Raise ArgumentError if an invalid method is specified as part of a route's conditions.  Also raise an error if HEAD is specified as the method, as rails routes all HEAD requests through the equivalent GET, though doesn't return the response body [#182 state:resolved]

Signed-off-by: Joshua Peek &lt;josh@joshpeek.com&gt;</message>
  <tree>6c7a23d8c91536a8e79d38372d710baffc42c8d2</tree>
  <committer>
    <name>Joshua Peek</name>
    <email>josh@joshpeek.com</email>
  </committer>
</commit>
