Is anything baked into ruby or rails to handle formatting for ordinals: '1' as '1st', '2' as '2nd', etc.?
Looks like you are looking for ordinalize:
The Ruby on Rails framework is chock full of interesting little nuggets. Ordinalize is a number extension that returns the corresponding ordinal number as a string. For instance, 1.ordinalize returns “1st” and 22.ordinalize return “22nd”.
Example:
place = 3 puts "You are currently in #{place.ordinalize} place."
Result:
You are currently in 3rd place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With