Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Inconsistent inflector behaviour for uncountable words in a multi-word string separated by underscores #7132

chancancode opened this Issue · 5 comments

5 participants

# Single-word + uncountables = no problem!
"information".singularize # => "information"
"information".pluralize # => "information"

# Multi-word + spaces + countables = no problem!
"weird bugs".singularize # => "weird bug"
"weird bug".pluralize # => "weird bugs"

# Multi-word + spaces + uncountables = no problem!
"funky jeans".pluralize # => "funky jeans"
"funky jeans".singularize # => "funky jeans"

# Multi-word + underscores + countables = no problem!
"weird_bugs".singularize # => "weird_bug"
"weird_bug".pluralize # => "weird_bugs"

# Multi-word + underscores + uncountables = BOOM!
"funky_jeans".singularize # => "funky_jean"
"client_information".pluralize # => "client_informations"

I consider this a bug because...
1. According to this test case, pluralizing/singularizing a multi-word string is a supported feature
2. According to this test cases, pluralizing/singularizing a multi-word string separated by underscores is a supported feature
3. tableize depends on 2.
4. "funky_jeans".singularize used to work before 9b4622a:

mbp:godfrey rails [(no branch)] $ git checkout baebe7d0d5c82cc7bb0570ae7d17a947f9bf58f7
HEAD is now at baebe7d... Avoid Bundler Resolver bug until they solve the issue
mbp:godfrey rails [(no branch)] $ irb -Iactivesupport/lib
>> require 'active_support/all'
=> true
>> 'funky_jeans'.singularize
=> "funky_jeans"

However, as far as I know, "client_information".pluralize have always been (incorrectly) returning "client_informations", meaning that fixing this might break certain apps out there. singularize and pluralize used to go through different code paths, but 52fa34f merged them into a single path, so it's no longer possible to just fix the bug introduced in 9b4622a without affecting the other direction as well. (I don't think that's a very reasonable behaviour anyways.)

@chancancode chancancode referenced this issue from a commit in chancancode/rails
@chancancode chancancode Correctly apply inflection rules on uncountable multi-word strings.
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.

Generally, the inflector is frozen. I'll defer to @fxn on this particular case, though.


+1 This is an irritating case that is easily fixed by applying this existing rules across the words

@fxn fxn was assigned

@fxn could you take a look?


Since the PR fixing this issue (#7134) has been rejected, this should probably be closed as well!

@chancancode chancancode closed this
fxn commented

Yeah, this is something that has been discussed in the past. Basically, the behaviour of singularize and friends on multi-word strings is undefined, their contract only includes whole words.

@rafaelfranca rafaelfranca removed the stale label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.