How to sort Rails AR.find by number of objects in a has_many relationship

前端 未结 7 2015
名媛妹妹
名媛妹妹 2020-12-24 09:32

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_man         


        
7条回答
  •  遥遥无期
    2020-12-24 09:46

    Your question doesn't make sense. The :order parameter specifies a column name and an optional ordering direction i.e. asc(ending) or desc(ending).

    What is the result that you're trying to achieve?

提交回复
热议问题