1
我有一个用户模型,它有许多战斗。扑灭属于用户。has_many,belongs_to association has_many关联模型在belongs_to中有两个别名fk associated_model
战斗表中有两个外键引用用户PK - challenger_id和challengee_id。
诀窍是如何在用户模型上编写has_many关联,以便返回其中user_id = challenger_id或challengee_id的战斗?
想这是比想象的简单:的has_many:打架,:foreign_key => 'challenger_id或challengee_id' – keruilin 2010-06-19 10:58:03