“select * from users,awards where(users.id = awards.user_id)和awards.trophy_id not in(select awards.trophy_id from awards awards awards.trophy_id =#{trophy.id})”
答案 0 :(得分:0)
回答了自己的问题:
named_scope:not_awarded_trophy,lambda {| trophy | {:include => :awards,:conditions => [“awards.trophy_id不在(选择awards.trophy_id来自奖项,其中awards.trophy_id =?)”,“trophy.id”} }