mongoid money field
This is a super simple gem to use RubyMoney money type columns with mongoid
A simple gem that creates a Money datatype using RubyMoney for Mongoid.
Inspired by gist.github.com/840500
v2.0 breaks compatibility as it does not give 0 cents default anymore. Use
money_field_with_options :price, default: 0
Include the gem in your Gemfile
class DummyMoney include Mongoid::Document include Mongoid::MoneyField field :description money_field :price, :old_price # to disallow changing currency (and to not store it in database) money_field_with_options :price2, fixed_currency: 'GBP' # set a default money_field_with_options :price3, default: '1.23 RUB' end
All Money values are converted and stored in mongo as cents and currency in two separate fields.
Finding by price
Copyright © 2012 glebtv. MIT License.