嵌套通过有很多关联

时间:2009-08-31 15:38:49

标签: ruby-on-rails

我在创建嵌套关联时遇到了一些麻烦,我无法发现正在发生的事情:

class Package < ActiveRecord::Base
  has_many :selections, :class_name => "PackageSelection"
  has_many :channels, :through => :selections
  has_many :categories, :through => :channels, :source => ?????
end

class Channel < ActiveRecord::Base
  belongs_to :category
  has_many :package_selections
  has_many :packages, :through => :package_selections 
end

class Category < ActiveRecord::Base
  has_many :channels
end

我想弄清楚如何建立与类别的关联。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

似乎这在Rails Core(目前为2.3)中是不可能的,但有人has written a plugin to allow it