Project

cratchit

0.0
No commit activity in last 3 years
No release in over 3 years
Ruby on Rails friendly money for ActiveRecord, built on RubyMoney.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.0.0

Runtime

>= 3.7.1
 Project Readme

Cratchit

This gem was developed for use in a company eCommerce project.

RubyMoney is easily the best money class for Ruby out there, but implementation as an ActiveRecord datatype has traditionally been prone to bugs and core level hacks. This gem aims to bring the incredible foundation of RubyMoney into the slick Ruby on Rails framework by exposing money as an ActiveRecord column type.

Recently, a nice gem came out to handle the same thing, and even came with a nice money type for migrations. However, by default it does not assume currency and does not appear to have form serialization support.

Be sure to check out nybblr.com for other Rails goodies, and if you're looking for more of my gems (when I get around to it!) take a stroll around my GitHub repos.

Usage

From your ActiveRecord model, simply call the money method:

class Product < ActiveRecord::Base
	# Example usages
	money :price

	money :price, :default => :zero

	money :price, :default => 10.99

	money :price, :default => Money.new(10, "EUR")

	money :price, :cents => "rate_in_cents", :include_prefix => false

end