module ActiveRecord::Locking::Pessimistic
def lock!(lock = true)
or pass true for "FOR UPDATE" (the default, an exclusive row lock). Returns
lock. Pass an SQL locking clause to append the end of the SELECT statement
Obtain a row lock on this record. Reloads the record to obtain the requested
def lock!(lock = true) reload(:lock => lock) if persisted? self end
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