views:

13

answers:

1

Hi all,

class Game < 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

+1  A: 

Try

named_scope :no_statistics, :include => :statistics, :conditions => ['statistics.id IS NULL']

zetetic