This project is archived and is in readonly mode.

#1089 ✓resolved
mamooth

polymorphic routes should handle collections through Model Class

Reported by mamooth | September 22nd, 2008 @ 11:28 AM

The rails 2.1 PolymorphicRoutes module should handle collection's url through Model Class :

In actionpack/test/controller/polymorphic_routes_test.rb :

def test_with_a_class
  expects(:articles_url).with()
  polymorphic_url(Article)
end

def test_with_a_class_in_an_array
  expects(:articles_url).with()
  polymorphic_url([Article])
end

def test_with_a_class_and_a_namespace
  expects(:admin_articles_url).with()
  polymorphic_url([:admin, Article])
end

in module ActionController module PolymorphicRoutes

 ...
   def polymorphic_url(record_or_hash_or_array, options = {})
   ...
   inflection =
   ...
   # adding
   when record.is_a?(Class)
      args.pop
      :plural
   # end adding => this allow a Class to be mapped to the collection
   ...
   end

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages