<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,7 @@
 *Edge*
 
+* Allow polymorphic_url helper to take url options. #880 [Tarmo T&#228;nav]
+
 * Switched integration test runner to use Rack processor instead of CGI [Josh Peek]
 
 * Made AbstractRequest.if_modified_sense return nil if the header could not be parsed [Jamis Buck]</diff>
      <filename>actionpack/CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -102,6 +102,12 @@ module ActionController
       args &lt;&lt; format if format
       
       named_route = build_named_route_call(record_or_hash_or_array, namespace, inflection, options)
+
+      url_options = options.except(:action, :routing_type, :format)
+      unless url_options.empty?
+        args.last.kind_of?(Hash) ? args.last.merge!(url_options) : args &lt;&lt; url_options
+      end
+
       send!(named_route, *args)
     end
 
@@ -114,19 +120,19 @@ module ActionController
 
     %w(edit new formatted).each do |action|
       module_eval &lt;&lt;-EOT, __FILE__, __LINE__
-        def #{action}_polymorphic_url(record_or_hash)
-          polymorphic_url(record_or_hash, :action =&gt; &quot;#{action}&quot;)
+        def #{action}_polymorphic_url(record_or_hash, options = {})
+          polymorphic_url(record_or_hash, options.merge(:action =&gt; &quot;#{action}&quot;))
         end
 
-        def #{action}_polymorphic_path(record_or_hash)
-          polymorphic_url(record_or_hash, :action =&gt; &quot;#{action}&quot;, :routing_type =&gt; :path)
+        def #{action}_polymorphic_path(record_or_hash, options = {})
+          polymorphic_url(record_or_hash, options.merge(:action =&gt; &quot;#{action}&quot;, :routing_type =&gt; :path))
         end
       EOT
     end
 
     private
       def action_prefix(options)
-        options[:action] ? &quot;#{options[:action]}_&quot; : &quot;&quot;
+        options[:action] ? &quot;#{options[:action]}_&quot; : options[:format] ? &quot;formatted_&quot; : &quot;&quot;
       end
 
       def routing_type(options)</diff>
      <filename>actionpack/lib/action_controller/polymorphic_routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -60,6 +60,18 @@ uses_mocha 'polymorphic URL helpers' do
       edit_polymorphic_url(@article)
     end
 
+    def test_url_helper_prefixed_with_edit_with_url_options
+      @article.save
+      expects(:edit_article_url).with(@article, :param1 =&gt; '10')
+      edit_polymorphic_url(@article, :param1 =&gt; '10')
+    end
+
+    def test_url_helper_with_url_options
+      @article.save
+      expects(:article_url).with(@article, :param1 =&gt; '10')
+      polymorphic_url(@article, :param1 =&gt; '10')
+    end
+
     def test_formatted_url_helper
       expects(:formatted_article_url).with(@article, :pdf)
       formatted_polymorphic_url([@article, :pdf])
@@ -67,10 +79,16 @@ uses_mocha 'polymorphic URL helpers' do
 
     def test_format_option
       @article.save
-      expects(:article_url).with(@article, :pdf)
+      expects(:formatted_article_url).with(@article, :pdf)
       polymorphic_url(@article, :format =&gt; :pdf)
     end
 
+    def test_format_option_with_url_options
+      @article.save
+      expects(:formatted_article_url).with(@article, :pdf, :param1 =&gt; '10')
+      polymorphic_url(@article, :format =&gt; :pdf, :param1 =&gt; '10')
+    end
+
     def test_id_and_format_option
       @article.save
       expects(:article_url).with(:id =&gt; @article, :format =&gt; :pdf)
@@ -147,7 +165,7 @@ uses_mocha 'polymorphic URL helpers' do
     def test_nesting_with_array_containing_singleton_resource_and_format_option
       @tag = Tag.new
       @tag.save
-      expects(:article_response_tag_url).with(@article, @tag, :pdf)
+      expects(:formatted_article_response_tag_url).with(@article, @tag, :pdf)
       polymorphic_url([@article, :response, @tag], :format =&gt; :pdf)
     end
 </diff>
      <filename>actionpack/test/controller/polymorphic_routes_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>654c41255d22b2767b943dbe970d8b24f2a1387b</id>
    </parent>
  </parents>
  <author>
    <name>Tarmo T&#228;nav</name>
    <email>tarmo@itech.ee</email>
  </author>
  <url>http://github.com/rails/rails/commit/98fb161dbb13feb18165468aedf1581d5c2305f4</url>
  <id>98fb161dbb13feb18165468aedf1581d5c2305f4</id>
  <committed-date>2008-08-21T12:26:00-07:00</committed-date>
  <authored-date>2008-08-21T10:26:05-07:00</authored-date>
  <message>Allow polymorphic_url helper to take url options. [#880 state:resolved]

All *_polymorphic_url, *_polymorphic_path helpers can now accept
an options hash which will be passed on to the named route
making it possible to generate polymorphic routes with additional
url parameters.

Signed-off-by: Pratik Naik &lt;pratiknaik@gmail.com&gt;</message>
  <tree>100a3192923dea387b59ef1b9364d3d940753b33</tree>
  <committer>
    <name>Pratik Naik</name>
    <email>pratiknaik@gmail.com</email>
  </committer>
</commit>
