Using the gem money rail https://github.com/RubyMoney/money-rails
I used the method earlier with_model_currency:
delegate :currency, :to => :edition, :prefix => true
monetize :base_fee_pennies, :allow_nil => true, :with_model_currency => :edition_currency
monetize :qm_fee_pennies, :allow_nil => true, :with_model_currency => :edition_currency
monetize :total_fee_pennies, :allow_nil => true, :with_model_currency => :edition_currency
But I'm trying to find a more concise way to do this, so instead of using with_model_currency3 times, so I started to directly override the method currency:
def currency
unless new_record?
Money::Currency.find(edition_currency)
end
end
But I found that I have problems with new records ... edition_id is set using the build method, but for some reason this does not work, I get errors that are not set, so I used a new_record?method that seems to fix it.
My question is whether I should do this, or if there is a more direct approach (besides creating a column).
Thanks,