'does with_lock lock everything inside the block?
Does with_lock lock all models in the block or just the model itself? For example in the following are all the item models inside with_lock locked or is just the entry model locked?
class Entry < ApplicationRecord
enum state: [:pending, :posted]
has_many :items, dependent: :destroy
def post!
with_lock do
return unless pending?
items.each { |i| i.post! }
self.posted!
end
end
end
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
