【发布时间】:2012-06-08 20:23:57
【问题描述】:
我想找到有孩子的东西。所以给定:
class Foo < ActiveRecord::Base
has_many :bars
has_many :bazes
scope :is_a_parent ...what goes here?...
我想得到有任何酒吧或任何 bazes 的 Foos。当然,使用原始 SQL,所有事情都是可能的,exists (select 1 from bars ...) or exists (select 1 from bazes ...),但是 yuk。
肯定有某种方法可以将 any? 与 arel or 方法结合使用吗?在不使用 SQL 的情况下还有其他方法吗?
【问题讨论】:
标签: ruby-on-rails-3 activerecord