Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
“从用户中选择*,奖励其中(users.id = Awards.user_id)和awards.trophy_id不在(从awards.trophy_id = #{trophy.id}的奖励中选择awards.trophy_id)”
回答了自己的问题:
命名范围:not_awarded_trophy,lambda { |奖杯| { :include => :awards, :conditions => [ "awards.trophy_id 不在(从 Awards where Awards.trophy_id = ?) 中选择 Awards.trophy_id", trophy.id ] } }