ruby on rails - Nested query for association -
campaign has_many:ads
ad
belongs_to: campaign has_many :likes
like
belongs_to :ad
i want count likes of ads in campaign.how query it?
add relation campaign
has_many :likes, through: :ads
after can use: campaign.likes.count
Comments
Post a Comment