https://github.com/mrkamel/increment_with_sql
Provides increment_with_sql! and decrement_with_sql! for ActiveRecord models
https://github.com/mrkamel/increment_with_sql
Last synced: over 1 year ago
JSON representation
Provides increment_with_sql! and decrement_with_sql! for ActiveRecord models
- Host: GitHub
- URL: https://github.com/mrkamel/increment_with_sql
- Owner: mrkamel
- License: mit
- Created: 2015-04-08T18:41:53.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2018-03-07T09:32:41.000Z (over 8 years ago)
- Last Synced: 2025-04-23T23:10:02.185Z (over 1 year ago)
- Language: Ruby
- Size: 13.7 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# IncrementWithSql
[](http://travis-ci.org/mrkamel/increment_with_sql)
[](https://gemnasium.com/mrkamel/increment_with_sql)
[](http://badge.fury.io/rb/increment_with_sql)
Provides `#increment_with_sql!` and `#decrement_with_sql!` for ActiveRecord::Base,
since ActiveRecord's bulti-in non-atomic `#increment` and `#decrement` methods don't
provide database consistency.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'increment_with_sql'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install increment_with_sql
## Usage
It's simple:
```ruby
class MyModel < ActiveRecord::Base
def increment_counter!
increment_with_sql! :counter
end
def decrement_counter!
decrement_with_sql! :counter
end
end
```
## Contributing
1. Fork it ( https://github.com/[my-github-username]/increment_with_sql/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request