RubyMoney/money · error · ArgumentError
'amount' must be numeric
Error message
'amount' must be numeric
What it means
Error "'amount' must be numeric" thrown in RubyMoney/money.
Source
Thrown at lib/money/money.rb:317
end
# Creates a new Money object of value given in the +unit+ of the given
# +currency+.
#
# @param [Numeric] amount The numerical value of the money.
# @param [Currency, String, Symbol] currency The currency format.
# @param [Hash] options Optional settings for the new Money instance
# @option [Money::Bank::*] :bank The exchange bank to use.
#
# @example
# Money.from_amount(23.45, "USD") # => #<Money fractional:2345 currency:USD>
# Money.from_amount(23.45, "JPY") # => #<Money fractional:23 currency:JPY>
#
# @return [Money]
#
# @see #initialize
def self.from_amount(amount, currency = default_currency, options = {})
raise ArgumentError, "'amount' must be numeric" unless amount.is_a?(Numeric)
currency = Currency.wrap(currency) || Money.default_currency
raise Currency::NoCurrency, "must provide a currency" if currency.nil?
value = amount.to_d * currency.subunit_to_unit
new(value, currency, options)
end
# DEPRECATED.
#
# @see Money.from_amount
def self.from_dollars(amount, currency = default_currency, options = {})
warn "[DEPRECATION] `Money.from_dollars` is deprecated in favor of " \
"`Money.from_amount`."
from_amount(amount, currency, options)
end
View on GitHub (pinned to 26e2829c34)
When it happens
Trigger: Thrown at lib/money/money.rb:317 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of RubyMoney/money@26e2829c34 (2026-08-23).
Data as JSON: /api/errors/7448c616940d5595.
Report an issue: GitHub.