I tried to get the exchange rate like this in my Rails app :
1.to_money.exchange_to('USD')
(Note : I have set the default currency to my local currency which is lkr
). This returns 0. Im using the money-rails
gem.
The answer can be found from the link @aurelius have posted. Without using exchange_to
, there's a direct way to get just the exchange rate. Since I use google currency
gem and have configured it as the default_bank
in the initializer, I can get the rate like this :
MoneyRails.default_bank.get_rate(:LKR, :USD)