In my application I have a Student and a Participation model with a has_many relation. I would like to sort the students based on their number of active participations (i.e., pa