meta-where

Want to find records with no associated records in Rails

情到浓时终转凉″ 提交于 2019-11-26 05:45:26
问题 Consider a simple association... class Person has_many :friends end class Friend belongs_to :person end What is the cleanest way to get all persons that have NO friends in ARel and/or meta_where? And then what about a has_many :through version class Person has_many :contacts has_many :friends, :through => :contacts, :uniq => true end class Friend has_many :contacts has_many :people, :through => :contacts, :uniq => true end class Contact belongs_to :friend belongs_to :person end I really don\