acts_as_follower
acts_as_follower copied to clipboard
Avoid n+1 queries
Is there a way to avoid n+1 queries?
I have a class Company:
class Company < ActiveRecord::Base
acts_as_followable
end
And I make a query to get a certain type of companies, but I want to get the followers of each one of those and I end up with n+1 queries:
SELECT COUNT(*) FROM "follows" WHERE "follows"."followable_id" = $1 AND "follows"."followable_type" = $2 AND "follows"."blocked" = $3 [["followable_id", 419], ["followable_type", "Company"], ["blocked", "f"]]
Anyone created a fork with optimized queries for this issue yet??