Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thbar/activerecord-experiments
https://github.com/thbar/activerecord-experiments
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/thbar/activerecord-experiments
- Owner: thbar
- Created: 2012-08-05T10:02:57.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-08-07T08:14:04.000Z (over 12 years ago)
- Last Synced: 2024-10-14T02:50:22.783Z (2 months ago)
- Language: Ruby
- Size: 102 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This repository is a playground around various ways to handle prices with ActiveRecord.
## Already implemented
#### DecimalPriceProduct
Uses a decimal column to implement the price attribute.
Issue: `price_before_type_cast` will equal `nil` even if you pass a blank string, so you cannot rely on `price_before_type_cast` to provide a different treatment to a blank input if needed.
Links:
- https://github.com/rails/rails/blob/4bbd05c90e5a62c0316307b3ca7c2262ed98b567/activemodel/lib/active_model/validations/numericality.rb#L95
## To be implemented
* composed_of (which was removed, then is back for now)
* custom accessors as advised on the commit that first removed composed_of
* money-rails (which implements a certain version of custom accessor)## How to run
Create `db/config.yml` based on 'db/config.yml.sample' then run:
```
bundle install
bundle exec rake db:create
bundle exec rake db:migrate
bundle exec rake spec
```