You are here: Browse Railsplugins Dollars And Cents
= dollars_and_cents plugin for Rails
A transparent handler for storing monetary values as integer fields in a database.
InstallationIf your project is source-controlled by Subversion (which it should be, really), the easiest way to install this is via Rails' plugin script:
./script/plugin install -x http://svn.codahale.com/dollars_and_cents/trunk
If you're not using Subversion, or if you don't want it adding svn:externals in your project, remove the -x switch:
./script/plugin install http://svn.codahale.com/dollars_and_cents/trunk
Usage
In this example, let’s assume we have a price we need to store in our database.
1. Create a database field named price_in_cents, of type INTEGER. 2. Access the price as follows: @product.price #=> 29.99 @product.price = 24.99 #=> 24.99 @product.price #=> 24.99
Resources = Subversion=== Blog
== Credits
Written by Coda Hale <coda>.
NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly