Intuitive extensions and utilities to handle money in multiple currencies for Ruby on Rails
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



cash_handler aims to be an intuitive (and useful) set of extensions and utilities to assist in handling money across different currencies for Ruby on Rails.

Requirements and Installation

  • Install the hpricot gem (gem install hpricot)
  • Install the cash_handler plugin (script/plugin install git://


  c =
  # Get the current exchange rate of the AUD against the USD (currency code strings are case in-sensitive, can also be symbols)
  => 0.619099
  # Get the current exchange rate of the AUD against the GBP
  c.get('AUD', :against => 'GBP')
  => 0.418621272567449
  # Convert
  c.convert(10, :aud, :usd)
  => 6.19099
  # Force the converstion rates cache to reload currencies
  # The CashHandler::Cache has a default cache life of one day, this can be overridden in one of two ways
  # Upon creation
  c = => 30.minutes)
  # During operation
  c.cache.ttl = 30.minutes

Backup rates in case is inaccessible

You may configure cash_handler to create a backup file every time it pulls rates from In the event that is inaccessible, the rates stored in the backup file will be used.

  # Configure cash_handler to persist rates to our app's log directory
  c = => "#{RAILS_ROOT}/tmp/rates.yml")

When working in a development or test environment with cache classes disabled, you may not want to fetch new rates with each request.

  # Will only force cache expiration on initialization => true) in a production environment.
  c = => Rails.env.production?)

Copyright and License

Copyright © 2008 James Brooks, released under the MIT license