我无法弄清楚如何使用活动记录来管理它。我知道它不处理外连接...
SQL:
SELECT * FROM people
LEFT OUTER JOIN responses
ON people.id = responses.person_id
WHERE responses.person_id is NULL;
模型:
Person
id
has_many :responses
Response
id
belongs_to :person
有什么建议吗?
答案 0 :(得分:1)
named_scope :without_responses, :include => :responses,
:conditions => "responses.id IS NULL"