Turn numbers into strings with thousands' separators
class Numeric def commify(dec='.', sep=',') num = to_s.sub(/\./, dec) dec = Regexp.escape dec num.reverse.gsub(/(\d\d\d)(?=\d)(?!\d*#{dec})/, "\\1#{sep}").reverse end end
So, you get:
1233232423424.23423.commify # => "1,233,232,423,424.23"