I can't figure out how to manage this purely with active record. I understand it doesn't handle outer joins...
我不知道如何用活动记录来管理这个。我理解它不处理外部连接……
SQL:
SQL:
SELECT * FROM people
LEFT OUTER JOIN responses
ON people.id = responses.person_id
WHERE responses.person_id is NULL;
MODELS:
模型:
Person
id
has_many :responses
Response
id
belongs_to :person
Any suggestions?
有什么建议吗?
1 个解决方案
#1
1
named_scope :without_responses, :include => :responses,
:conditions => "responses.id IS NULL"
#1
1
named_scope :without_responses, :include => :responses,
:conditions => "responses.id IS NULL"