0
我有模型代表关联规则(车身=>头)问题查找轨
def Item
has_many :heads
has_many :bodies
...
end
def Rule
has_many :heads
has_many :bodies
...
end
def Body
belongs_to :item
belongs_to :rule
...
end
def Head
belongs_to :item
belongs_to :rule
...
end
我想找到具有匹配的指定团体的项目的项目,并希望通过规则来访问它的头部规则,但连接表我不能这样做
def Rule
has_many :heads
has_many :bodies
has_many :item, :through => :heads
has_many :item, :through => :bodies
...
end
我应该改变什么,并做到这一点?
感谢,
我应该有head_items和body_items模型作为项目的继承吗? – sarunw 2009-11-16 16:31:06