我有这样的:我应该否定has_many has_many?
class User < ActiveRecord::Base
has_many :serials
has_many :sites, :through => :series
end
class Serial < ActiveRecord::Base
belongs_to :user
belongs_to :site
has_many :episodes
end
class Site < ActiveRecord::Base
has_many :serials
has_many :users, :through => :serials
end
class Episode < ActiveRecord::Base
belongs_to :serial
end
我愿做User.serials.episodes一些操作,但我知道这将意味着各种聪明的把戏。理论上我可以将所有的情节数据串入(denormalize),然后在需要时将group_by Site。
如果我有很多剧集需要查询,这是不是一个好主意?
谢谢