我有两个型号:汽车和图片在我的回报率的项目查找父母没有或在轨多态关联孩子
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