Foobar.find(1).votes_count
返回 0。
在 Rails 控制台中,我正在做:
10.times { Resque.enqueue(AddCountToFoobar, 1) }
我的resque工人:
class AddCountToFoobar
@queue = :low
def self.perform(id)
foobar = Foobar.find(id)
foobar.update_attributes(:count => foobar.votes_count +1)
end
end
我希望Foobar.find(1).votes_count
是10
,但它返回 4。如果我10.times { Resque.enqueue(AddCountToFoobar, 1) }
再次运行,它会返回相同的行为。它只增加votes_count
4,有时增加 5。
谁能解释一下?