Tuesday, February 9, 2010

You are here: Home > Articles > Quick trick for using “classify”

Quick trick for using “classify”

by Damien on February 24, 2008

Here’s a little trick I used to get the classify string method to work right. I was having a problem that just using classify was turning e.g. “stock_status” into “StockStatu”, which is obviously incorrect, even though I had the correct line in “config/initializers/inflection.rb”. The simple fix was to pluralize the string first, e.g. “stock_status”.pluralize.classify returns the correct “StockStatus”.

Bookmark and Share
  • Dan
    Have you thought about submitting a failing test case to the Rails Trac site? I can imaging that tables with the word "status" would be reasonably common, so it probably should be fixed.
  • Don't bother submitting a test case/patch. "The inflector is closed" (quoted from Trac last time I tried to fix the inflector's shortcomings).

    I can add this to my plugin, acts_as_good_speeler, which fixes most or all of the bad inflections.
blog comments powered by Disqus

Previous post:

Next post: