开发者

How to do this sql with pure activerecord (rails)

I can't figure out how to manage this purely with active record. I understand it doesn't handle outer joins...

SQL:

SELECT * FROM people 
LEFT OUTER JOIN responses 
ON people.id = respo开发者_运维问答nses.person_id 
WHERE responses.person_id is NULL;

MODELS:

Person
id
has_many :responses

Response
id
belongs_to :person

Any suggestions?


named_scope :without_responses, :include    => :responses, 
                                :conditions => "responses.id IS NULL"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜