Correctly apply inflection rules on multi-word strings. (Fixes #7132) #7134

wants to merge 2 commits into
Commits on Jul 23, 2012
  1. Correctly apply inflection rules on uncountable multi-word strings.

    chancancode committed Jul 23, 2012
    Currently, apply_inflections does not take into account that the input might be a multi-word string separated by underscore. (tableize etc relies on this behavior to work correctly.) This bug affects only uncountable multi-word strings separated by underscores:
       "funky jeans".singularize # => "funky jeans"
       "client information".pluralize # => "client information"
       "funky_jeans".singularize # => "funky_jean"
       "client_information".pluralize # => "client_informations"
    It's also worth pointing out that "funky_jeans".singularize used to work correctly before 9b4622a, which was merged almost 2 years ago so this is essentially broken since Rails 3.
    On the other hand, it appears that "client_information".pluralize has always been broken, so this does change the behavior of tableize and could potentially break some older apps out there.
    Closes #7132.
  2. Correctly handle phrases in singularize/pluralize.

    chancancode committed Jul 23, 2012
    Currently, the inflector is not set up correctly to handle phrases
    (multi-word strings) as input. This ocasionally works right now, but it
    is more or less a coincidence. Since Rails internally depend on this
    singularize/pluraize being able to handle phrases (see tableize), this
    commit fixes the bug and correctly handle phrases in singularize and
    pluralize. The following should work as expected after this patch:
       'MyClass'.pluralize # => 'MyClasses'
       'some-slug'.pluralize # => 'some-slugs'
       'saw_fish'.pluralize # => 'saw_fish'
       'optical mouse'.pluralize # => 'optical mice'
       'funky jeans'.singularize # => 'funky jeans'
    See #7134 for discussions.