假设我有:
class Town < ActiveRecord::Base
has_many :citizens
end
class Citizen < ActiveRecord::Base
belongs_to :town
has_many :cars
end
class Car < ActiveRecord::Base
belongs_to :citizen
end
使用 ActiveRecord,我可以获得镇上汽车数量的最简单方法是什么?
假设我有:
class Town < ActiveRecord::Base
has_many :citizens
end
class Citizen < ActiveRecord::Base
belongs_to :town
has_many :cars
end
class Car < ActiveRecord::Base
belongs_to :citizen
end
使用 ActiveRecord,我可以获得镇上汽车数量的最简单方法是什么?