KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How can I write an AR find query to have the results ordered by the number of records in a has_many association? class User < ActiveRecord::Base has_many :photos end I want to do something like... User.find(:all, :order => photos.count) I realize my find is not valid code. Say I have the following data. User 1, which has 3 photos User 2, which has 5 photos User 3, which has 2 photos I want my find to bring me back the users in the order of... User 2, User 1, User 3 based on the count of of the users photos
Tags (comma-separated)
Save Edits
Cancel