Pluralize Bug

“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

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

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

...
"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

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

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.

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

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

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

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.

Sounds good. http://dev.rubyonrails.org/changeset/4868

jeremy

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

jeremy

> 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 :wink:

Thanks for the fix!

Mark