instance method
lock!
Ruby on Rails 4.0.13
Since v2.2.3Signature
lock!(lock = true)
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.
Parameters
-
lockopt = true
Source
# File activerecord/lib/active_record/locking/pessimistic.rb, line 61
def lock!(lock = true)
reload(:lock => lock) if persisted?
self
end
Defined in activerecord/lib/active_record/locking/pessimistic.rb line 61
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Locking::Pessimistic