RubyMoney/money · error · Money::Bank::DifferentCurrencyError
No exchanging of currencies allowed: #{from} #{from.currency
Error message
No exchanging of currencies allowed: #{from} #{from.currency} to #{to_currency} What it means
Error "No exchanging of currencies allowed: #{from} #{from.currency} to #{to_currency}" thrown in RubyMoney/money.
Source
Thrown at lib/money/bank/single_currency.rb:21
require "money/bank/base"
class Money
module Bank
# Raised when trying to exchange currencies
class DifferentCurrencyError < Error; end
# Class to ensure client code is operating in a single currency
# by raising if an exchange attempts to happen.
#
# This is useful when an application uses multiple currencies but
# it usually deals with only one currency at a time so any arithmetic
# where exchanges happen are erroneous. Using this as the default bank
# means that that these mistakes don't silently do the wrong thing.
class SingleCurrency < Base
# Raises a DifferentCurrencyError to remove possibility of accidentally
# exchanging currencies
def exchange_with(from, to_currency, &)
raise DifferentCurrencyError, "No exchanging of currencies allowed: #{from} #{from.currency} to #{to_currency}"
end
end
end
end
View on GitHub (pinned to 26e2829c34)
When it happens
Trigger: Thrown at lib/money/bank/single_currency.rb:21 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/8775bdd6157dbfdd.
Report an issue: GitHub.