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