method

with_lock

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).