RubyMoney/money · error · Money::Currency::NoCurrency

must provide a currency

Error message

must provide a currency

What it means

Error "must provide a currency" thrown in RubyMoney/money.

Source

Thrown at lib/money/money.rb:320

  # +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

  # Creates a new Money object of value given in the
  # +fractional unit+ of the given +currency+.
  #

View on GitHub (pinned to 26e2829c34)

When it happens

Trigger: Thrown at lib/money/money.rb:320 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/6c15ea710104b91d. Report an issue: GitHub.