我试图进行元搜索,或者一个范围,它给我所有没有任何has_many-association等于type ==“Something”的对象。
例子:
class Order < ActiveRecord::Base
has_many :billing_base
end
class InvoiceBase < ActiveRecord::Base
belongs_to :order
end
class Invoice < InvoiceBase
end
class OrderAcknowledgement < InvoiceBase
end
通过自定义范围轻松搜索具有发票的订单:
joins(:invoice_base).where(:invoice_base => {:type => "Invoice"})
或元搜索:
:invoice_base_type_equals => "Invoice"
现在我该如何做相反的事情,找到没有发票的订单?(OrderAcknowledgements 应该总是被允许的)