Question about query

Hi guys, I have the following problem: In my application there is 3 entities that have this relationship: -1 post has many comments -1 comment belongs to one user and to one post -1 comment could be voted by many users My problem is how can I make a query to search for the best rated comment, in other words, How can I get the comment from one user which has the most quantity of good votes? I don't know how to make this query... ;/

my entities are structure like this:

class Post < ActiveRecord::Base   belongs_to :user   belongs_to :post_type   has_many :post_comments end

class PostComment < ActiveRecord::Base   belongs_to :user   belongs_to :post   has_many :post_comment_votes end

class PostCommentVote < ActiveRecord::Base   belongs_to :vote_type   belongs_to :user   belongs_to :post_comment end

class VoteType < ActiveRecord::Base   has_many :post_comment_votes end

Thx ;D