Rails currency exchange gem that works?

柔情痞子 提交于 2019-12-05 14:48:42

I picked google_currency from your list as most popular and it has been recently maintained. It worked fine for me, I ran the code from the synopsis without a problem.

If you saw the message:

You are using an old or stdlib version of json gem
Please upgrade to the recent version by adding this to your Gemfile:

  gem 'json', '~> 1.7.7'

Then you may need to update your copy of multi_json to avoid the json deprecation warnings:

gem install json
gem install multi_json

Which should (at the time of writing) install json 1.8.0 and multi_json 1.7.8. Or of course, if this is for a project, you should be able to pick these versions in your Gemfile, provided there is no conflict with other libraries in your project. The message may of caused you concern, but it is not a problem with google_currency.

I didn't notice any conflict or problems with the google_currency gem, using either the deprecated JSON modules or the most recent ones. To do something similar to what you want:

require 'money'
require 'money/bank/google_currency'

bank = Money::Bank::GoogleCurrency.new
bank.get_rate(:GBP, :USD).to_f
 => 1.5513
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!