我有一个代表参加(因为连接具有属性)的模型来实现一个的habtm关系:与加入模型rails habtm - 如何找到未链接的记录?
class Person
has_many :person_photos
end
class PersonPhoto
# has a person and a photo id, and a couple of
# other attributes that aren't relevant
end
class Photo
has_many :person_photos
end
我想一个方法添加到照片类获取的人是一个列表不是在那张照片。对于我的生活,我无法弄清楚。这很容易吗?
我喜欢这个的简单性,但它生成的SQL是:SELECT'people'。* FROM'people' WHERE(id NOT IN 1,2)和barfs。 – 2012-01-04 03:28:46
啊 - 包括括号?它的工作原理! (我编辑了解决它的答案。)谢谢! – 2012-01-04 03:32:38
哦,我认为我们同时编辑。 :-) – 2012-01-04 03:33:22