module ActiveRecord::Locking::Pessimistic
def with_lock(lock = true)
before yielding. You can pass the SQL locking clause
Wraps the passed block in a transaction, locking the object
def with_lock(lock = true) transaction do lock!(lock) yield end end