lock!(lock = true)public
Obtain a row lock on this record. Reloads the record to obtain the requested lock. Pass an SQL locking clause to append the end of the SELECT statement or pass true for “FOR UPDATE” (the default, an exclusive row lock). Returns the locked record.
# File activerecord/lib/active_record/locking/pessimistic.rb, line 61 def lock!(lock = true) reload(:lock => lock) if persisted? self end
Of course, this has to be done in a transaction, like so: