module ActiveSupport::NumberHelper

def number_to_currency(number, options = {})

# => "$1,234,567,891"
number_to_currency(1234567890.50, precision: 0, round_mode: :up)
# => "$1,234,567,890.5"
number_to_currency(1234567890.50, strip_insignificant_zeros: true)
# => "1234567890,50 £"
number_to_currency(1234567890.50, unit: '£', separator: ',', delimiter: '', format: '%n %u')
# => "£1234567890,50"
number_to_currency(1234567890.50, unit: '£', separator: ',', delimiter: '')
# => "($1,234,567,890.50)"
number_to_currency(-1234567890.50, negative_format: '(%u%n)')
# => "$0"
number_to_currency(-0.456789, precision: 0)

number_to_currency('123a456') # => "$123a456"
number_to_currency(1234567890.506, locale: :fr) # => "1 234 567 890,51 €"
number_to_currency(1234567890.506, precision: 3) # => "$1,234,567,890.506"
number_to_currency(1234567890.506) # => "$1,234,567,890.51"
number_to_currency(1234567890.50) # => "$1,234,567,890.50"

==== Examples

+false+).
insignificant zeros after the decimal separator (defaults to
* :strip_insignificant_zeros - If +true+ removes
absolute value of the number.
than :format, except %n is here the
number given by :format). Accepts the same fields
numbers (defaults to prepending a hyphen to the formatted
* :negative_format - Sets the format for negative
currency, and %n for the number.
(defaults to "%u%n"). Fields are %u for the
* :format - Sets the format for non-negative numbers
to ",").
* :delimiter - Sets the thousands delimiter (defaults
(defaults to ".").
* :separator - Sets the separator between the units
(defaults to "$").
* :unit - Sets the denomination of the currency
(defaults to :default. See BigDecimal::mode)
* :round_mode - Determine how rounding is performed
to 2).
* :precision - Sets the level of precision (defaults
(defaults to current locale).
* :locale - Sets the locale to be used for formatting

==== Options

using a library capable of currency conversion.
may want to specify a constant :locale option or consider
this helper. If your application will ever support multiple locales, you
also be able to change the relative value of the currency displayed with
is performed. If the user is given a way to change their locale, they will
unless otherwise specified in the provided options. No currency conversion
The currency unit and number formatting of the current locale will be used

can customize the format in the +options+ hash.
Formats a +number+ into a currency string (e.g., $13.65). You
def number_to_currency(number, options = {})
  NumberToCurrencyConverter.convert(number, options)
end