开发者

How to translate this MySQL statement into named_scope method?

"select * from users, awards where (users.id = awards.use开发者_如何学JAVAr_id) and awards.trophy_id not in (select awards.trophy_id from awards where awards.trophy_id = #{trophy.id})"


Answered own question:

named_scope :not_awarded_trophy, lambda { |trophy| { :include => :awards, :conditions => [ "awards.trophy_id not in (select awards.trophy_id from awards where awards.trophy_id = ?)", trophy.id ] } }

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜