active_exchange

Active Exchange is a Rails Engine based Gem that is using the XavierMedia API. You can now get daily Exchange rates that are then uploaded into your own ExchangeRate table in the Database for use inside your Rails app.

Using a Rake task, that is ran once a day, you collect all the exchange rate information.

Now inside your rails app, you can convert one currency into another, or save everything into one currency on the fly.

By going to XavierMedia once a day, you get stable rates to use throughout the day, which should be sufficient enough for your online store.

I personally wouldn’t use this if my model was, say an F/X trader on a big time exchange where second by second data is needed, however.

Usage

  • add gem ‘active_exchange’ to your GEMFILE (Rails 3)

  • For now: Copy the rake file and migration into your app’s (for rake) lib/task directory and (for migration file)db/migrate – Will fix later hopefully.

  • Run “rake db:migrate” to migrate the migration files.

  • Run the rake task : “sudo rake active_exchange:daily_seed” to get yesterday’s closing Exchange Rate data (When doing today’s it’s hit and miss).

You can now integrate the data into your app as you see fit.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but

    bump version in a commit by itself I can ignore when I pull)
    
  • Send me a pull request. Bonus points for topic branches.

Copyright © 2009 pjammer. See LICENSE for details. MIT.