A gentle reminder about pluralizations
Posted by josh May 17, 2006 @ 07:55 PM
Watching the RSS feed from the Ruby on Rails trac is a great way to keep up on what's happening in Rails development. If you're doing any development on the Ruby on Rails project it's required reading. Even if you just are using Rails for a web app, it's useful to keep up on what bugs people are reporting.
Lately I've noticed a slew of bugs being opened against the Inflector, the class in Rails that transforms words from one form to another: singular to plural, classname to tablename, etc. The bugs all complain that Inflector is getting a pluralization or singularization wrong. But this isn't a bug in Inflector, it is just an inherent limitation of how it works. But fear not, there is a better solution than opening a bug against the Inflector.
I guess this has been a constant thing over the history of Rails, but since it's still going on, it deserves a rehash.

Nice writeup. I noticed the Inflector addition to the config file when 1.0 came out.
It upsets me that so many people have completely missed it though, and, instead of looking around first, feel the need to write a bug report.
But… the outcome is all that matters, so education before anger. :)
That effectively means a lot of duplicate work being done by countless developers when it could be wrapped up in the next release to help future generations of rails conductors.
Well I’m actually glad people are putting effort in writing bug reports. Many people reporting many (duplicated / unnecessary) bugs isn’t a bad thing at all. Is there actually a place people can post their own inflections, so it prevents many people writing duplicate inflections? (It isn’t much work to write one, but still)
There are a few special cases in the code, aren’t there? As long as those exist, people will continue to file bugs expecting other special cases.
However, there are a few that NEED to be fixed. Rails can’t even pluralize “database” correctly.
That being said… The pluralize text helper method is also broken in my opinion. Instead of giving the plural form of a word it actually toggles between the plural form and the singular. “Categories”.pluralize => “Category” I can see the logic, sort of, but calling it pluralize is wrong.
I think one main problem is that there seem to be names that are just not allowed cause they are reserved words – but nobody seems to be able to tell me how I can figure out which name will cause a conflict without digging through the whole rails code.
I want to make clear that this entry is not about bug reports, but about patches. I submitted a patch for “aircraft” to be added to the default list, because I believe that has more real world applications than “sheep” and “fish” which are currently default ones.
I respectfully disagree with a blanket “inflector-is-perfect policy”.
Saying, “you can manually get around this” is not an answer for people who are willing to do some statistical dirty work to find out the most common model names that need to be listed and perhaps have “fish” and “sheep” removed from the list. Having sensible defaults, right?
I want to say that I understand the fear that there will be thousands of patches all which argue one way or the other about inflector. And, I would happily accept this policy if the current list even seemed to have mostly words that are used in real life contexts.
I just thought that this would be a good learning experience for doing a test-patch to get used to the process and get my feet wet before I start on other things.
However, realizing that I’m in the minority, I’m going to pick my battles and keep my “aircraft” patch closed. I have much better patches on the way that are indeed worth fighting for.
I must say, pluralization is the one design feature of Rails I can’t see any sense in.
Perhaps I’m showing my ignorance, but please can someone explain to me the benefits? For the life of me, I can’t see what’s wrong with storing, say, information for a ‘Product’ object in the ‘Product’ table. What could be simpler! It works when people want to use a language other than English to name things too.
Ok, done my research now and found the earlier weblog which explains all. Turns out the reason is because it was a joke. Good one, and I fell for it too!
I call bullshit. Let’s file patches and let’s build up a decent pluralization corpus.