In Ruby on Rails (3) with PostgreSQL and given the following three hierarchical models:
class Category
has_many :posts
end
class Post
belongs_to :category
has_many :comments
end
class Comment
belongs_to :post
end
Is there a way to get the total comment
count for each category
without having to iterate over each of the posts
?
Any help would be appreciated, thank you!
Aucun commentaire:
Enregistrer un commentaire