Method: ActiveRecord::Locking::Pessimistic#lock!
- Defined in:
- lib/active_record/locking/pessimistic.rb
#lock!(lock = true) ⇒ Object
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.
49 50 51 52 |
# File 'lib/active_record/locking/pessimistic.rb', line 49 def lock!(lock = true) reload(:lock => lock) unless new_record? self end |