我有一個代表參加(因爲連接具有屬性)的模型來實現一個的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