rails/rails — pull request #11410 by bogdan (2013-07-12 13:17:01+00:00)
Title: Make AR#increment! AR#decrement! concurency safe

`increment!` and `decrement!` should be concurency safe because
incorrect update can cause serious problems.

Especially when rails already have a concurency-safe counters update
mechanics in `.update_counters` method.

So this patch includes the following changes:

* Reuse code between increment and decrement methods
* Extracted a code snippet (search for ultimate 'eww' comment in diff)
from has_many association internals to #increment! method
* Make use of `#increment!` and `#decrement!` methods where possible
instead of `.update_counters` that doesn't update an counters on
record instance level