【发布时间】:2011-06-18 04:18:00
【问题描述】:
我有以下表格:
manufacturers
* id
* name
* description
types
* id
* name
* description
* manufacturer_id
cars
* id
* title
* description
* type_id
现在我的问题是,我想列出汽车的类型和制造商,例如:
* Some Car, Fiat Punto
* Another Car, Ferrari F1
...
在rails中我可以设置制造商关系。像这样:
class Car < ActiveRecord::Base
belongs_to :type
has_one :manufacturer, :through => :type
end
这在 Yii 中也可以吗?
【问题讨论】:
标签: activerecord relationship yii has-many-through