Reputation: 7043
I am using the Money gem for handling transaction amounts. I'd like to use different currencies for different transactions (but without conversions). The default currency is set in the money.rb:
config.default_currency = :usd
Even though I can set different currencies when creating a Transaction, the view always shows the amount in US dollars. For example this 12.00 transaction with RUB as currency:
<Transaction id: 100, amount_cents: 1200, currency: "RUB", created_at: "2013-12-11 09:32:52", updated_at: "2013-12-11 09:32:52">
Is being shown as a USD transaction in my views.
<% transactions.each do |transaction| %>
<%= transaction.amount_cents.to_money.format %>
...
=> $12.00
Here's the code from my Transaction.rb (just in case I'm missing something)
composed_of :amount_cents,
class_name: 'Money',
mapping: %w(amount_cents cents),
converter: Proc.new { |value| value.respond_to?(:to_money) ? value.to_money : Money.empty }
monetize :amount_cents, as: "amount"
Any ideas on how to override the default? I'll be thankful for any advice.
Upvotes: 1
Views: 672