Make numbers more readable in a Rails view
Rails has a number of handy helper methods.
Specifically, in ActionView::Helpers::NumberHelper there is the method number_with_delimiter
If you want to display the number 100000 and have people know right away whether it is 1 million or 100 thousand, just pass it to number_with_delimiter
and it will return "100,000"
.
Some useful optional keyword parameters:
delimiter:"🍔"
replaces the default ,
delimiter. (100000 becomes 100🍔000)
separator:"🍕"
replaces the default .
separator. (100.56 becomes 100🍕56)