0

Instead of having a integer _cents field, and a _currency string field, I've created a Currency model, which has:

  • iso_code
  • usd_rate (the exchange rate to USD)
  • name

Examples:

  • USD
    • iso_code: "USD"
    • usd_rate: 1
    • name: "American Dollars"

Do you know how can I do to integrate this model with the money-rails gem? (I mean, for having a reference to the currency instead of saving the iso_code, and for using the exchange rate in the currency model)

ascherman
  • 1,762
  • 2
  • 20
  • 41

1 Answers1

1

Have you tried using the provided initializer to change the config.amount_column and config.currency_column options? Changing the column_name options in these might let you change it to a method name that returns the your currency model's attributes, and allow the gem to work its magic.

hluckenb
  • 36
  • 1
  • 2
  • Yes, I could do that, but after changing the currency column type to integer, it loads USD as the currency. How can I specify that this is a reference to another table? Otherwise it is just a number and it doesn't know which currency the number is – ascherman Aug 02 '16 at 21:59