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
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
Try
named_scope :no_statistics, :include => :statistics, :conditions => ['statistics.id IS NULL']