Is there a way to use a model association inside the :order part of a Rails find? For example, I have the following scenario:
User
has_many :lists
end
#fields include: count is an int, best is a boolean and only only list has best equal true
List
belongs_to :user
end
I would like to perform a find that orders the users by the count value of the users best list. I know this totally doesn't work, but maybe it will help get my goal across:
User.find_all_by_id_and_profile(user_ids, true, :order => "user.lists.find_by_best(true).count")
I've read about using :include, but I'm not sure how that would apply here.