返回没有关联数据的对象

时间:2010-10-19 15:43:59

标签: ruby-on-rails

class Game < Event  
  has_many :statistics, :dependent => :destroy

  ...
end

class Statistic < ActiveRecord::Base
  belongs_to :game
end

我想创建一个只返回没有统计信息的游戏的命名范围。

由于

1 个答案:

答案 0 :(得分:2)

尝试

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

相关问题