I found this add-on for the Money gem which updates from the ECB European Central Bank (updates its rates every 24 hours) but I'm unsure how I should go about caching in my rails app which uses multiple currencies.
http://github.com/RubyMoney/eu_central_bank
eu_bank ||= EuCentralBank.new
eu_bank.update_rates
#Rails.cache.fetch('rates', :expires_in => 24.hours) { eu_bank.update_rates }
rate = eu_bank.exchange_with(Money.new(100, session[:currency]), "USD").to_f
It has a function to write out the rates to some file... but i'm not sure that's what I want either. I'm also using heroku which has a read-only file system.
eu_bank.save_rates("/some/file/location/exchange_rates.xml")
I couldn't find any way to check the age on the object either. I'm just wondering the best option to load it once per 24 hours and persist for my entire Rails app. Any pointers?