2009-11-04 97 views

回答

1

可以使用nested_has_many_through插件,它可以讓你做的事:

class ModelA 
    has_many :model_bs 
    has_many :model_cs, :through => :modelbs 
    has_many :model_es, :through => :modelcs 
end 

class ModelB 
    belongs_to :model_as 
    belongs_to :model_cs 
end 

class ModelC 
    has_many :model_bs 
    has_many :model_ds 
    has_many :model_as, :through => :modelbs 
    has_many :model_es, :through => :modelcs 
end 

+0

正是我需要的。謝謝! – penger 2009-11-05 13:47:22