开发者

2-way polymorphic association

I have a two-way polymorphic association.

I have Assignments and Resources and they each can have one of a wikipage, weblink, or file.

So a wikipage would belong_to :assignment or a Resource and an Assignment would have_one contentable (wikipage, weblink, or file).

Any idea on how to set it up?

UPDATE

This is my curent thought. Since I will not look up assignments or resources from wikipages/web links/files, I will make assignments and resources belong to a contentable so that the foreign key and type will be in the assignments and resources table. This will 开发者_如何转开发allow me to get the contentable from the assignment and resource class through the association. Wikipages etc. will not have an association Which is okay because I don't need it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜