Reputation: 4933
For some reason, Sidekiq gives me back 0 records for a query, after being triggered in an after_create
.
However, if process
would have sleep 1
in it, it ALWAYS gives me the correct value (1 record).
What the hell is going on here?
Model:
after_create :after_create
def after_create
AwardsWorker.perform_async(user_id)
end
Worker:
def perform(user_id)
user = User.find(user_id)
AwardEngine.added_shows_awards(user)
end
AwardEngine:
def self.added_shows_awards(user)
count = user.followings(true).count #(true) to avoid AR caching
puts "count: #{count}" #this is mostly 0! even if the database has 1 record
end
Upvotes: 1
Views: 870