MixedNumber
Store mixed numbers in an ActiveRecord model seamlessly with built-in validation.
Installation
Add this line to your application's Gemfile:
gem 'mixed_number_rails'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mixed_number_rails
Usage
rails_mixed_number is based on my general purpose mixed_number ruby gem. Go there for examples on using MixedNumber objects.
Hooking up with Rails
- Create a model with a string attribute
? rails g model Item amount:string
- Open the model file you just generated and add
mixed_number_attribute
with the name of your attributeclass Item < ActiveRecord::Base mixed_number_attribute :amount end
- Your attribute will now be a mixed number, with validation.
Contributing
- Fork it ( https://github.com/tpadjen/mixed_number_rails/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request