<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -597,11 +597,11 @@ module ActionController
         end
 
         map_resource_routes(map, resource, :index, resource.path, index_route_name)
-        map_resource_routes(map, resource, :create, resource.path)
+        map_resource_routes(map, resource, :create, resource.path, index_route_name)
       end
 
       def map_default_singleton_actions(map, resource)
-        map_resource_routes(map, resource, :create, resource.path)
+        map_resource_routes(map, resource, :create, resource.path, &quot;#{resource.shallow_name_prefix}#{resource.singular}&quot;)
       end
 
       def map_new_actions(map, resource)
@@ -632,9 +632,10 @@ module ActionController
           end
         end
 
-        map_resource_routes(map, resource, :show, resource.member_path, &quot;#{resource.shallow_name_prefix}#{resource.singular}&quot;)
-        map_resource_routes(map, resource, :update, resource.member_path)
-        map_resource_routes(map, resource, :destroy, resource.member_path)
+        route_path = &quot;#{resource.shallow_name_prefix}#{resource.singular}&quot;
+        map_resource_routes(map, resource, :show, resource.member_path, route_path)
+        map_resource_routes(map, resource, :update, resource.member_path, route_path)
+        map_resource_routes(map, resource, :destroy, resource.member_path, route_path)
       end
 
       def map_resource_routes(map, resource, action, route_path, route_name = nil, method = nil)
@@ -642,7 +643,7 @@ module ActionController
           action_options = action_options_for(action, resource, method)
           formatted_route_path = &quot;#{route_path}.:format&quot;
 
-          if route_name
+          if route_name &amp;&amp; @set.named_routes[route_name.to_sym].nil?
             map.named_route(route_name, route_path, action_options)
             map.named_route(&quot;formatted_#{route_name}&quot;, formatted_route_path, action_options)
           else</diff>
      <filename>actionpack/lib/action_controller/resources.rb</filename>
    </modified>
    <modified>
      <diff>@@ -822,6 +822,84 @@ class ResourcesTest &lt; Test::Unit::TestCase
     end
   end
 
+  def test_resource_has_only_create_action_and_named_route
+    with_routing do |set|
+      set.draw do |map|
+        map.resources :products, :only =&gt; :create
+      end
+
+      assert_resource_allowed_routes('products', {},                    { :id =&gt; '1' }, :create, [:index, :new, :show, :edit, :update, :destroy])
+      assert_resource_allowed_routes('products', { :format =&gt; 'xml' },  { :id =&gt; '1' }, :create, [:index, :new, :show, :edit, :update, :destroy])
+
+      assert_not_nil set.named_routes[:products]
+    end
+  end
+
+  def test_resource_has_only_update_action_and_named_route
+    with_routing do |set|
+      set.draw do |map|
+        map.resources :products, :only =&gt; :update
+      end
+
+      assert_resource_allowed_routes('products', {},                    { :id =&gt; '1' }, :update, [:index, :new, :create, :show, :edit, :destroy])
+      assert_resource_allowed_routes('products', { :format =&gt; 'xml' },  { :id =&gt; '1' }, :update, [:index, :new, :create, :show, :edit, :destroy])
+
+      assert_not_nil set.named_routes[:product]
+    end
+  end
+
+  def test_resource_has_only_destroy_action_and_named_route
+    with_routing do |set|
+      set.draw do |map|
+        map.resources :products, :only =&gt; :destroy
+      end
+
+      assert_resource_allowed_routes('products', {},                    { :id =&gt; '1' }, :destroy, [:index, :new, :create, :show, :edit, :update])
+      assert_resource_allowed_routes('products', { :format =&gt; 'xml' },  { :id =&gt; '1' }, :destroy, [:index, :new, :create, :show, :edit, :update])
+
+      assert_not_nil set.named_routes[:product]
+    end
+  end
+
+  def test_singleton_resource_has_only_create_action_and_named_route
+    with_routing do |set|
+      set.draw do |map|
+        map.resource :account, :only =&gt; :create
+      end
+
+      assert_singleton_resource_allowed_routes('accounts', {},                    :create, [:new, :show, :edit, :update, :destroy])
+      assert_singleton_resource_allowed_routes('accounts', { :format =&gt; 'xml' },  :create, [:new, :show, :edit, :update, :destroy])
+
+      assert_not_nil set.named_routes[:account]
+    end
+  end
+
+  def test_singleton_resource_has_only_update_action_and_named_route
+    with_routing do |set|
+      set.draw do |map|
+        map.resource :account, :only =&gt; :update
+      end
+
+      assert_singleton_resource_allowed_routes('accounts', {},                    :update, [:new, :create, :show, :edit, :destroy])
+      assert_singleton_resource_allowed_routes('accounts', { :format =&gt; 'xml' },  :update, [:new, :create, :show, :edit, :destroy])
+
+      assert_not_nil set.named_routes[:account]
+    end
+  end
+
+  def test_singleton_resource_has_only_destroy_action_and_named_route
+    with_routing do |set|
+      set.draw do |map|
+        map.resource :account, :only =&gt; :destroy
+      end
+
+      assert_singleton_resource_allowed_routes('accounts', {},                    :destroy, [:new, :create, :show, :edit, :update])
+      assert_singleton_resource_allowed_routes('accounts', { :format =&gt; 'xml' },  :destroy, [:new, :create, :show, :edit, :update])
+
+      assert_not_nil set.named_routes[:account]
+    end
+  end
+
   def test_resource_has_only_collection_action
     with_routing do |set|
       set.draw do |map|</diff>
      <filename>actionpack/test/controller/resources_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>57d795bad43d4a3e5eef7151099a8e40808a1031</id>
    </parent>
  </parents>
  <author>
    <name>Tom Stuart</name>
    <login>tomstuart</login>
    <email>tom@experthuman.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/4c0921024471c0463d67f8b8fb6a115a94d343aa</url>
  <id>4c0921024471c0463d67f8b8fb6a115a94d343aa</id>
  <committed-date>2008-11-13T08:49:09-08:00</committed-date>
  <authored-date>2008-11-13T06:31:36-08:00</authored-date>
  <message>Fix map.resources to always generate named routes if they're needed

Signed-off-by: Michael Koziarski &lt;michael@koziarski.com&gt;</message>
  <tree>c0611632d1d4cf43934378dd6113ab381d6cdb6b</tree>
  <committer>
    <name>Michael Koziarski</name>
    <login>NZKoz</login>
    <email>michael@koziarski.com</email>
  </committer>
</commit>
