我有兩個型號:汽車和圖片在我的回報率的項目查找父母沒有或在軌多態關聯孩子
class Car < ActiveRecord::Base
has_many :pictures, :as => :imageable, :dependent => :destroy
end
和
class Picture < ActiveRecord::Base
belongs_to :imageable, :polymorphic => true, :dependent => :destroy
end
我怎樣才能找到所有隻有兒童圖片的汽車?
感謝您的解決方案!它爲我工作。我只是修正了一個小表達式:conditions => [「pictures.imageable_id IS NOT NULL」] – 2010-06-21 16:24:39