b_d b_d - 4 months ago 59
Ruby Question

Convert 1200 to 1.2K in ruby/rails

I think there is a method within ruby or rails that does this but I can't remember where to find it or how to search for it, so I was hoping stackoverflow's collective wisdom might help.
I don't mind writing a method to do this, but I'm sure someone has a better solution.

number_to_human(1200, :format => '%n%u', :units => { :thousand => 'K' })

# 1200 => 1.2K