You are here: Browse Railsplugins Rails Money
= Rails Money
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> money / 3 => [#<money:0xb76b3e14>, #<money:0xb76b3f2c>, #<money:0xb76b3f04>]
All other operations (+, -, *, and Comparable stuff) will work without any surprises or magic.
Installation./script/plugin install svn://svn.nullcreations.net/plugins/rails_money
UsageCreate 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>
== Feedback
Any suggestions, fixes, or improvements – lemme know, jerrett at gmail
NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly