The Inflector Module – Another Reason to Love Rails

I love how when you need something in Rails the solution is usually already in place. For instance in the indulgenc.es application I have the need to create a rank with 1st, 2nd, 3rd etc. In most frameworks you would have to write this functionality yourself or if you are very lucky you might find something on the Internet. In Rails you do this:


number.ordinalize

Then 1 becomes 1st, 2 becomes 2nd, 1233 becomes 1233rd etc.

I am still smiling