0.0
The project is in a healthy, maintained state
Money attributes to ActiveRecord
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 7.1.3.2
>= 0.3
 Project Readme

Minting::Rails

Minting::Rails is a gem that provides money attributes to ActiveRecord models. It integrates the Minting library into your Rails application.

Installation

Add this line to your application's Gemfile:

gem 'minting-rails'

And then execute:

  bundle

Configuration

After intalling generate Minting configuration initializer:

rails g mint:initializer

You can configure the default currency for your application by adding the following line to your config/initializers/minting.rb:

Minting.configure do |config|
  config.default_currency = :usd
end

Usage

To use Minting::Rails, you add the money_attribute method to your ActiveRecord models. For example:

class SimpleOffer < ApplicationRecord
  money_attribute :price, currency: 'USD'
  money_attribute :discount, currency: 'USD'
end

Now you can use the price attribute as a Money object:

product = Product.ne(price: 100)
puts product.price # => "$100.00"

To do

  • API Documentation
  • Internationalization
  • Publish 1.0 Beta

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.