How can I find records by “count” of association using rails and mongoid?
问题 With these models: class Week has_many :proofs end class Proof belongs_to :week end I want to do something like: Week.where(:proof.count.gt => 0) To find only weeks that have multiple proofs. There is one answer that seems to address this: Can rails scopes filter on the number of associated classes for a given field But in this example, there is no such attribute as proof_ids in Week since the ids are stored with the proofs. This does not work for example: Week.where(:proof_ids.gt => 0) How