class Game开发者_StackOverflow < Event
has_many :statistics, :dependent => :destroy
...
end
class Statistic < ActiveRecord::Base
belongs_to :game
end
I want to make a named scope that only returns games that have no statistics.
Thanks
Try
named_scope :no_statistics, :include => :statistics, :conditions => ['statistics.id IS NULL']
精彩评论