在这种情况下,常规多态关联是否有效?

时间:2012-05-31 03:09:12

标签: ruby-on-rails ruby-on-rails-3 associations polymorphic-associations

我有四个模型和这些关联

forums
  belongs to user
  has many topics
topics
  belongs to user AND forum (at the same time)
  has many posts
posts
  belongs to topic AND user (at the same time)
users
  has many forums
  has many topics
  has many posts

我想弄清楚的问题是如何处理

topics  
  belongs to user AND forum (at the same time)
posts
  belongs to topic AND user (at the same time)

It seems like regular polymorphic association only supports cases where you have EITHER OR scenario rather than AND scenario.

因此,例如,我认为常规多态关联仅支持像

这样的情况
comments
  belongs to EITHER photo OR blog

而不是

comments
  belongs to posts AND commenter

常规多态关联会起作用吗?如果没有,我还有其他选择吗?

0 个答案:

没有答案