Reputation: 8730
Campaign
has_many:ads
Ad
belongs_to: campaign
has_many :likes
Like
belongs_to :ad
I want to count the likes of all ads in campaign.How I query it?
Upvotes: 1
Views: 56
Reputation: 91
Add relation to Campaign
has_many :likes, through: :ads
after that you can use: campaign.likes.count
Upvotes: 2