Using ActiveRecord's #update_counters to Prevent Race Conditions
Race conditions are arguably the most insidious kind of bug; they're intermittent, subtle, and most likely to occur in production. ActiveRecord's update_counter
provides us with a convenient way to avoid race conditions when incrementing or decrementing values in the database. In this article, Jonathan Miles shows us how to use it, how it's implemented, and other approaches to avoiding race conditions.