Questions tagged «meta-where»

8
想要在Rails中查找没有关联记录的记录
考虑一个简单的关联... class Person has_many :friends end class Friend belongs_to :person end 在Arel和/或meta_where中,让所有没有朋友的人最干净的方法是什么? 然后has_many:through版本呢? 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 我真的不想使用counter_cache-从我阅读的内容来看,它不适用于has_many:through 我不想拉所有的person.friends记录并在Ruby中遍历它们-我想要一个可以与meta_search gem一起使用的查询/范围 我不在乎查询的性能成本 …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.