method
with_lock
v7.0.0 -
Show latest stable
- Class:
ActiveRecord::Locking::Pessimistic
with_lock(*args)public
Wraps the passed block in a transaction, locking the object before yielding. You can pass the SQL locking clause as an optional argument (see #lock!).
You can also pass options like requires_new:, isolation:, and joinable: to the wrapping transaction (see ActiveRecord::ConnectionAdapters::DatabaseStatements#transaction).