Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
scope :with_fans_counter, -> {
select <<~SQL
influencers.*,
(
SELECT COUNT(fan_influencers.id) FROM fan_influencers
WHERE influencer_id = influencers.id
) AS fans_count
SQL
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment