# Pluralize Bug

**URL:** <https://discuss.rubyonrails.org/t/pluralize-bug/356>\
**Category:** rubyonrails-core\
**Created:** [August 23, 2006, 9:32pm UTC](https://discuss.rubyonrails.org/t/pluralize-bug/356 "2006-08-23T21:32:46Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Van\_Holstyn1](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@Mark\_Van\_Holstyn1](https://discuss.rubyonrails.org/u/Mark_Van_Holstyn1)\
**Post date:** [August 23, 2006, 9:32pm UTC](https://discuss.rubyonrails.org/t/pluralize-bug/356/1 "2006-08-23T21:32:46Z")

</div>

> > “territories”.pluralize =\> “territory” “queries”.pluralize =\> “query”

This matches the rule: [/([^aeiouy]|qu)ies$/i, “\1y”

Is this a bug, or are there times where a word ending in “ies” should be pluralized with “y”?

I tried to create a ticket for this issue, bu track keeps giving me the error “Akismet rejected spam”

Thanks, Mark

---

<div class="post-metadata">

**Author:** ![Jakob\_Skjerning](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@Jakob\_Skjerning](https://discuss.rubyonrails.org/u/Jakob_Skjerning)\
**Post date:** [August 24, 2006, 5:44am UTC](https://discuss.rubyonrails.org/t/pluralize-bug/356/2 "2006-08-24T05:44:07Z")

</div>

I'm curious. What would you expect them to be pluralized as? "territorieses" and "querieses"?

---

<div class="post-metadata">

**Author:** ![Rob\_Sanheim](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@Rob\_Sanheim](https://discuss.rubyonrails.org/u/Rob_Sanheim)\
**Post date:** [August 24, 2006, 6:39am UTC](https://discuss.rubyonrails.org/t/pluralize-bug/356/3 "2006-08-24T06:39:07Z")

</div>

I would expect it to return the word unchanged, as per the examples given in the docs: [http://caboo.se/doc/classes/ActiveSupport/CoreExtensions/String/Inflections.html#M004173](http://caboo.se/doc/classes/ActiveSupport/CoreExtensions/String/Inflections.html#M004173)

... "sheep".pluralize #=\> "sheep" "words".pluralize #=\> "words" "the blue mailman".pluralize #=\> "the blue mailmen"

Although that behavior should probably also be specified in the rdoc in addition to examples. Maybe "if you pass in a string already pluralized or a string for which no valid pluralization exists, the string is returned unchanged."

- Rob

---

<div class="post-metadata">

**Author:** ![Kevin\_Clark](https://avatars.discourse-cdn.com/v4/letter/k/ad7895/32.png) [@Kevin\_Clark](https://discuss.rubyonrails.org/u/Kevin_Clark)\
**Post date:** [August 24, 2006, 6:53am UTC](https://discuss.rubyonrails.org/t/pluralize-bug/356/4 "2006-08-24T06:53:42Z")

</div>

The docs are wrong. pluralize has always returned a singular when given a plural.

---

<div class="post-metadata">

**Author:** ![Mark\_Van\_Holstyn1](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@Mark\_Van\_Holstyn1](https://discuss.rubyonrails.org/u/Mark_Van_Holstyn1)\
**Post date:** [August 24, 2006, 7:09am UTC](https://discuss.rubyonrails.org/t/pluralize-bug/356/5 "2006-08-24T07:09:12Z")

</div>

> I’m curious. What would you expect them to be pluralized as? “territorieses” and “querieses”?

I agree with Rob.

> The docs are wrong. pluralize has always returned a singular when
> 
> given a plural.

It makes no sense to return the singularized work. Currently, the word IS returned unchanges, except for the \*ies words.

---

<div class="post-metadata">

**Author:** ![Rob\_Sanheim](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@Rob\_Sanheim](https://discuss.rubyonrails.org/u/Rob_Sanheim)\
**Post date:** [August 24, 2006, 7:14am UTC](https://discuss.rubyonrails.org/t/pluralize-bug/356/6 "2006-08-24T07:14:07Z")

</div>

> The docs are wrong. pluralize has always returned a singular when given a plural.

Are you talking about pluralize in text helper, or the extension to String? Because thats not the case when using it with a regular ole' string:

This is with rails 1.1.6: C:\dev\workspace\_myec\madrails\>ruby script/console Loading development environment.

> > "dogs".pluralize

=\> "dogs"

> > "cats".pluralize

=\> "cats"

> > a = "table"

=\> "table"

> > a.pluralize

=\> "tables"

> > a.pluralize

=\> "tables"

> >

Maybe the helpers work differently...though from glancing at the source it doesn't look it. Any why would pluralize return the singular form? Thats what "singularize" is for, after all.

- Rob

---

<div class="post-metadata">

**Author:** ![Thibaut\_Barrere](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/thibaut_barrere/32/1594_2.png) [@Thibaut\_Barrere](https://discuss.rubyonrails.org/u/Thibaut_Barrere)\
**Post date:** [August 24, 2006, 8:25am UTC](https://discuss.rubyonrails.org/t/pluralize-bug/356/7 "2006-08-24T08:25:49Z")

</div>

Hi!

(rails 1.1.6, script/console, win32) Loading development environment.

> > “queries”.pluralize =\> “query”

> > “dogs”.pluralize =\> “dogs”

So pluralize actually singularizes words ending with ‘ies’, but leaves those dogs in group.

Sounds like a bug to me (or at least, an inconsistent behaviour which could be clarified - I’d expect pluralize to leave the plural form unaffected).

Thibaut

---

<div class="post-metadata">

**Author:** ![foamdino](https://avatars.discourse-cdn.com/v4/letter/f/cab0a1/32.png) [@foamdino](https://discuss.rubyonrails.org/u/foamdino)\
**Post date:** [August 30, 2006, 4:37am UTC](https://discuss.rubyonrails.org/t/pluralize-bug/356/8 "2006-08-30T04:37:52Z")

</div>

This is a bug in activesupport/lib/active\_support/inflections.rb

Somehow the singular form is included as a plural form, immediately after the plural, so what happens in the Inflector.pluralize method call is queries.pluralize -\> query -\> queries

Anyway it's a trivial fix:

Index: ../lib/active\_support/inflections.rb

---

<div class="post-metadata">

**Author:** ![Michael\_Koziarski1](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@Michael\_Koziarski1](https://discuss.rubyonrails.org/u/Michael_Koziarski1)\
**Post date:** [August 30, 2006, 4:57am UTC](https://discuss.rubyonrails.org/t/pluralize-bug/356/9 "2006-08-30T04:57:37Z")

</div>

The inflector is basically frozen, prior to 1.0 we'd add lots of new rules to fix bugs, and just end up enraging people who looked at the old output and named their tables accordingly. You can add those exceptions yourself in environment.rb.

---

<div class="post-metadata">

**Author:** ![bitsweat](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/bitsweat/32/591_2.png) [@bitsweat](https://discuss.rubyonrails.org/u/bitsweat)\
**Post date:** [August 30, 2006, 5:11am UTC](https://discuss.rubyonrails.org/t/pluralize-bug/356/10 "2006-08-30T05:11:03Z")

</div>

Sounds good. [http://dev.rubyonrails.org/changeset/4868](http://dev.rubyonrails.org/changeset/4868)

jeremy

---

<div class="post-metadata">

**Author:** ![bitsweat](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/bitsweat/32/591_2.png) [@bitsweat](https://discuss.rubyonrails.org/u/bitsweat)\
**Post date:** [August 30, 2006, 5:21am UTC](https://discuss.rubyonrails.org/t/pluralize-bug/356/11 "2006-08-30T05:21:38Z")

</div>

My bad. This one seemed bunk, probably an old typo.

jeremy

---

<div class="post-metadata">

**Author:** ![Michael\_Koziarski1](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@Michael\_Koziarski1](https://discuss.rubyonrails.org/u/Michael_Koziarski1)\
**Post date:** [August 30, 2006, 5:50am UTC](https://discuss.rubyonrails.org/t/pluralize-bug/356/12 "2006-08-30T05:50:06Z")

</div>

> \> The inflector is basically frozen, prior to 1.0 we'd add lots of new \> rules to fix bugs, and just end up enraging people who looked at the \> old output and named their tables accordingly. You can add those \> exceptions yourself in environment.rb.
> 
> My bad. This one seemed bunk, probably an old typo.

I did say \*basically\* frozen, you just agree to fix any breakages 😉

---

<div class="post-metadata">

**Author:** ![Mark\_Van\_Holstyn1](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@Mark\_Van\_Holstyn1](https://discuss.rubyonrails.org/u/Mark_Van_Holstyn1)\
**Post date:** [August 30, 2006, 11:39am UTC](https://discuss.rubyonrails.org/t/pluralize-bug/356/13 "2006-08-30T11:39:38Z")

</div>

Thanks for the fix!

Mark
