2
class Game < Event
has_many :statistics, :dependent => :destroy
...
end
class Statistic < ActiveRecord::Base
belongs_to :game
end
我想创建一个仅返回没有统计数据的游戏的命名范围。返回没有关联数据的对象
感谢
class Game < Event
has_many :statistics, :dependent => :destroy
...
end
class Statistic < ActiveRecord::Base
belongs_to :game
end
我想创建一个仅返回没有统计数据的游戏的命名范围。返回没有关联数据的对象
感谢
尝试
named_scope :no_statistics, :include => :statistics, :conditions => ['statistics.id IS NULL']