Project

has_money

0.01
No commit activity in last 3 years
No release in over 3 years
Parsing the various ways people enter dollar amounts so you don't have to. Store values in cents as integer.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8.4
~> 2.8.0
 Project Readme

has_money¶ ↑

Usage¶ ↑

In your ActiveRecord model:

class Order < ActiveRecord::Base
  has_money :default_price
end

Defines methods :default_price_in_dollars and :default_price_in_dollars= which make life easier when building forms.

> Order.new :default_price_in_dollars => '10.00'
=> #<Order default_price: 1000>

If you want to store your prices in cents but offer a form input that rounds to the nearest dollar

> order = Order.new :default_price_in_dollars_without_cents => '9.99'
=> #<Order default_price: 1000>
> order.default_price_in_dollars_without_cents
=> '10'

Install¶ ↑

As a gem:

$ gem install has_money

In your ‘Gemfile`:

gem 'has_money'

As a plugin:

script/plugin install git://github.com/samvincent/has_money.git