Getting count by drilling down through relations
问题 I'm using Rails 4 and I want to get a count of votes for each individual post review for a given post. Schema: Post PostReview PostReviewVote id post_id post_review_id user_id user_id voted_on_date I have something like: table.table.table-striped.table-hover thead tr th Post Name th Reviews Created For Post th Total Votes in All Reviews For Post tbody - for post in @posts tr td= post.name td= PostReview.where(post_id: post.id).size td= PostReview.where(post_id: post.id).PostReviewVotes.size