This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Wed Feb 28 16:31:29 -0800 2007 | |
| |
README | Mon Jan 05 17:55:29 -0800 2009 | |
| |
init.rb | Sun May 27 23:49:05 -0700 2007 | |
| |
lib/ | ||
| |
test/ |
README
= Rails Money Note! This is NOT compatible with the 'money' gem! A handler for storing money in ActiveRecord objects as integers (as cents), but dealing with them as Money Objects. Note: Dividing a money object will return an array of Money objects. This ensures cents do not go missing. For example: >> money = Money.new(10.00) => #<Money:0xb76b3e14 @cents=1000> >> money / 3 => [#<Money:0xb76b3e14 @cents=433>, #<Money:0xb76b3f2c @cents=333>, #<Money:0xb76b3f04 @cents=333>] All other operations (+, -, *, and Comparable stuff) will work without any surprises or magic. == Usage 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 >> #<Money @cents=10000> 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) == Feedback Any suggestions, fixes, or improvements - lemme know, jerrett at gmail








