Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Make polymorphic_url more consistent with routing code

#2212

In 2.3.1 (and before), there is a subtle difference in the handling of certain irregular plurals between RESTful routing and polymorphic_url. This shows up any time that you have inflections that do not round-trip between singular and plural. For example, out of the box Rails inflections include:


"tax".pluralize => "taxes"
"taxes".singularize => "taxis"

In this situation, some things will fail to work as expected. With the routes entry:


map.resources :taxes

A simple call to redirect_to @tax with a Tax object will fail, because (ultimately) routing uses the singularized pluralized name and polymorphic_url uses the singular name.

Attached patch corrects this situation so that polymorphic_url will work correctly on these names - in this particular case, it would redirect to (the correct) taxis_url instead of (the incorrect) tax_url.

Applying this patch is a prerequisite to getting a good fix for #2046 Strange pluralize and routing/

Reported by CancelProfileIsBroken · March 11th, 2009 @ 01:13 PM

State: resolved
Milestone: 2.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Repository
    Repository
    • State changed from new to resolved

    (from [d771e7d17f4a2c175676f7c8354aa5b161b63c2e]) Handle irregular plurals in polymorphic_urls [#2212 Make polymorphic_url more consistent with routing code state:resolved]

    Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...

    March 12th, 2009 @ 05:04 PM