This project is archived and is in readonly mode.

#1521 ✓invalid
Seth Ladd

Strings That End in class Are Not Properly Singularized

Reported by Seth Ladd | December 5th, 2008 @ 11:02 PM | in 2.x

This is minor, but inflections.rb probably should have a case for strings that look like /^(.)class$/ and perhaps even more generic as /^(.)ss$/

Currently, calling "event_class".singularize returns "event_clas" Adding inflect.singular /^(.*)class$/, '\1class' fixes it.

I noticed that inflections.rb you already have a special case to handle trailing 'ss' : inflect.plural(/(x|ch|ss|sh)$/i, '\1es') inflect.singular(/(x|ch|ss|sh)es$/i, '\1')

but since most strings that already are singular are properly handled when calling singularize ("foo".singularize returns "foo") it probably makes sense to handle the case of "class".singularize == "class"

Thanks

Comments and changes to this ticket

  • Frederick Cheung

    Frederick Cheung December 7th, 2008 @ 02:47 PM

    • State changed from “new” to “invalid”

    To quote inflector.rb:

    The Rails core team has stated patches for the inflections library will not be accepted in order to avoid breaking legacy applications which may be relying on errant inflections. If you discover an incorrect inflection and require it for your application, you'll need to correct it yourself (explained below).

    Sorry!

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>

People watching this ticket

Pages