喜多关系,我想创建Rails的关系。许多到不同的对象id_s存储在differen对象
我有战士模型,法师模型和模型派。
我想建立这样的关系:
warrior model can have_many factions
mage model can have many factions.
Faction model can have many warriors and mages
如何创建战士和法师的对象和派别对象之间的关系,将存储id_s两个战士和法师属于特定派系/派别?
所以,当我打电话:
faction.warriors I get warriors of specific faction.
faction.mage I get mages of this faction
warriors.faction I get the warrior faction.
mage.faction I get the mage faction.
我在想的多态关联。但它只有一个所有者。
任何线索?
我这个标记为正确的,但最终我用的has_many虽然。但是这个答案仍然是正确的。 – Kazik