Let’s say I have a model called Topic. A Topic has_many :topic_flags (a TopicFlag is used to denote content that has been flagged as inappropriate). My question is this: how can I select the Topics with the most flags (limited at an arbitrary amount, descending)? I’ve thought about it for a while, and while I can hack together an SQL query, I’d prefer to find a more Rails way of doing it.
Let’s say I have a model called Topic. A Topic has_many :topic_flags (a TopicFlag
Share
This uses an inner join, so it won’t pick up Topics with zero flags. You’d call it like this.