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 71 def lock!(lock = true) reload(:lock => lock) unless new_record? self end
Of course, this has to be done in a transaction, like so: