Rails Money plugin

Plugin details

A handler for storing money in ActiveRecord objects as integers (as cents), but dealing with them as Money Objects.

Websitehttp://www.nullcreations.net Repositorysvn://svn.nullcreations.net/plugins/rails_money Author Jerrett Taylor Tags money, integer LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install svn://svn.nullcreations.net/plugins/rails_money

Create your tables with fields named FIELDNAME_in_cents and you will be able to access them as
FIELDNAME. ActiveRecord will return Money objects instead of Fixnums.

  add_column :products, :price_in_cents, :integer
 
  product = Product.find_first
  product.price = 100.00
  product.price >> #


Creating a Money can be done from a Fixnum (dollars) or a Float (dollars.cents). To create a money object from just cents, do Money.create_from_cents(100)

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | Back in time (2 older versions) | Last edited by: jerrett, 10 months ago