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.

Incorrect inflectors for 'business' or '*ness'

#2399

Hi there.

I'm using activesupport 2.3.2, and found a simple inflector error.


>> require "activesupport"
=> true
>> "business".singularize
=> "busines"
>> "madness".singularize
=> "madnes"

But plurals and handled nicely.


>> "business".pluralize
=> "businesses"
>> "madness".pluralize
=> "madnesses"

Reported by Paulo Pereira · April 2nd, 2009 @ 11:24 AM

State: wontfix
Milestone: 2.x
Assigned to: nobody
Importance: Low

Activity

  1. Michelangelo Altamore
    Michelangelo Altamore
    • Tag set to activesupport, inflections, inflector

    Paulo you're right. I've found that singular words ending in 'ess' like:

    business, address, express, dress, press

    are singularized wrongly since the current inflections do not contain a proper rule. I propose to include such rule, that you can find attached along with tests.

    Example:

    Before patch

    "address".singularize => "addres" "address".classify => "Addres"

    After patch "Address"

    "address".singularize => "address" "address".classify => "Address"

    April 3rd, 2009 @ 02:00 PM

  2. José Valim
    José Valim
    1. Address is a quite common case and patch works.

    May 13th, 2009 @ 09:02 PM

  3. CancelProfileIsBroken
    CancelProfileIsBroken
    • State changed from new to wontfix

    Rails has a longstanding policy of not taking further inflector patches. Use an initializer in your application instead.

    May 17th, 2009 @ 01:37 PM

  4. Michelangelo Altamore
    Michelangelo Altamore

    Hello Mike,
    thank you for your response. In case of erratic behaviour of the inflector,
    that's enough to add a rule to the inflector initializer and stay neat and
    simple.
    Just for clarity, the problem raised by Paulo will be solved by adding the
    following:

    ActiveSupport::Inflector.inflections do |inflect|

    inflect.singular(/ess$/i, 'ess')
    

    end

    to the file:

    config/initializers/inflections.rb

    Thank you.

    May 24th, 2009 @ 11:02 PM

  5. Jeff Kreeftmeijer
    Jeff Kreeftmeijer
    • Tag cleared.
    • Importance changed from to Low

    Automatic cleanup of spam.

    November 7th, 2010 @ 04:55 PM

  6. Christopher Thompson
    Christopher Thompson

    Another workaround. Instead of:

    s = 'Address'
    s.singularize # 'Addres'
    

    Do:

    s = 'Address'
    s.pluralize.singularize # 'Address'
    

    Note that this affects the behaviour of .classify as well, but still s.pluralize.classify will work around it.

    November 25th, 2010 @ 05:02 PM

  7. Christopher Thompson
    Christopher Thompson

    In ticket #6057 'Address' does not singularize properly, Andrés Mejía asked:

    "Rails has a longstanding policy of not taking further inflector patches."

    May I ask what is the reason behind this?

    I'd also like to know the answer for this. I can imagine that patches tend to break other cases, so maybe that's the reason. But for such a long-standing problem that affects Rails 2.3.x and 3.x, I'm surprised to still see this as an issue.

    November 25th, 2010 @ 05:05 PM