config/initializers/money.rb
# encoding : utf-8
Money.locale_backend = :i18n
MoneyRails.configure do |config|
# To set the default currency
#
# Set default bank object
#
# Example:
# config.default_bank = EuCentralBank.new
# Add exchange rates to current money bank object.
# (The conversion rate refers to one direction only)
#
# Example:
# config.add_rate "USD", "CAD", 1.24515
# config.add_rate "CAD", "USD", 0.803115
# To handle the inclusion of validations for monetized fields
# The default value is true
#
# config.include_validations = true
# Default ActiveRecord migration configuration values for columns:
#
config.amount_column = { prefix: '', # column name prefix
postfix: '_subunits', # column name postfix
column_name: nil, # full column name (overrides prefix, postfix and accessor name)
type: :bigint, # column type
present: true, # column will be created
null: false, # other options will be treated as column options
default: 0
}
config.currency_column = { prefix: '',
postfix: '_currency',
column_name: nil,
type: :string,
present: true,
null: false,
default: 'US8'
}
config.register_currency = {
:priority => 1,
:iso_code => :us8,
:name => "US Dollar with subunit of 8 digits",
:symbol => "$",
:symbol_first => true,
:subunit => "Subcent",
:subunit_to_unit => 100_000_000,
:thousands_separator => ",",
:decimal_mark => "."
}
config.add_rate "USD", "US8", 1
config.add_rate "US8", "USD", 1
config.default_currency = :us8
# Register a custom currency
#
# Example:
# config.register_currency = {
# :priority => 1,
# :iso_code => "EU4",
# :name => "Euro with subunit of 4 digits",
# :symbol => "€",
# :symbol_first => true,
# :subunit => "Subcent",
# :subunit_to_unit => 10000,
# :thousands_separator => ".",
# :decimal_mark => ","
# }
# Specify a rounding mode
# Any one of:
#
# BigDecimal::ROUND_UP,
# BigDecimal::ROUND_DOWN,
# BigDecimal::ROUND_HALF_UP,
# BigDecimal::ROUND_HALF_DOWN,
# BigDecimal::ROUND_HALF_EVEN,
# BigDecimal::ROUND_CEILING,
# BigDecimal::ROUND_FLOOR
#
# set to BigDecimal::ROUND_HALF_EVEN by default
#
config.rounding_mode = BigDecimal::ROUND_HALF_EVEN
# Set default money format globally.
# Default value is nil meaning "ignore this option".
# Example:
#
# config.default_format = {
# :no_cents_if_whole => nil,
# :symbol => nil,
# :sign_before_symbol => nil
# }
# Set default raise_error_on_money_parsing option
# It will be raise error if assigned different currency
# The default value is false
#
# Example:
# config.raise_error_on_money_parsing = false
end