ActionView::Helpers::NumberHelper
def number_to_human(number, options = {})

Description

Formats the number as a human-readable string with a unit name.

Arguments

Changing a value updates the ERB and HTML.

Converts the number to a string using ActiveSupport::NumberHelper. The format comes from Rails' built-in English translations (number.human, etc.). A non-numeric value ("abc") is returned as is instead of raising an error. Returns nil for nil.
options= {}
{unit: "m", thousand: "km"}
A hash of unit names, with keys such as unit, thousand and million. Uses whichever of the given units fits the number. The unit names are escaped.
"%n%u"
The format, where %n is replaced with the number and %u with the unit. The given string is escaped.
true raises InvalidNumberError when the number argument is not a number.

Rounding options

1
The number of significant digits, or the number of digits after the decimal point when the :significant option is false.
true treats precision as the number of significant digits. false treats it as the number of digits after the decimal point. When precision is 0, rounds to an integer even if this is true.
true removes trailing 0s after the decimal point. false keeps 0s up to precision digits.
How to round: :down rounds toward zero and :up rounds away from zero. Defaults to rounding half up. Other BigDecimal rounding modes (:half_even, :half_down, :ceiling, :floor, etc.) also work.
","
The string used for the decimal point. It is escaped.
"."
The string inserted every three digits. It is escaped.Used only when the number is 1000 or more after dividing by the unit (without :units, beyond Quadrillion; with :units, beyond the largest unit given). If it is the same as the separator (.), removing trailing zeros also removes the zeros after the delimiter, so the number looks different (1.230 km becomes 1.23 km).
Every NumberHelper helper handles the rounding options the same way (ActiveSupport::NumberHelper's NumberToRoundedConverter). Their defaults differ from helper to helper.Options not listed here do not become HTML attributes. With :locale, uses that language's number format translations (number.human.decimal_units, etc.). This site provides no number format translations, so :ja gets Rails' built-in English format (a language this site does not have raises I18n::InvalidLocale).

ERB

Changes from the previous output: Added Removed Changed


          

HTML