- Feb
- 24
- 2008
Quick trick for using “classify”
By: Damien McKenna | Tags: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”.
Share this post
Related Posts
You can skip to the end and leave a response. Pinging is currently not allowed.


2 Responses to “Quick trick for using “classify””
On February 24th, 2008 at 4:23 pm Dan said:
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.
On February 25th, 2008 at 10:52 am Jeremy said:
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.