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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.