假设我想构建类似 tumblr 的东西,这是一种博客,其中的帖子可以是多种内容之一(文本、引用、图像、链接等)。
我可以使用简单的关联,例如...
Class Blog < ActiveRecord::Base
has_many :quotes
has_many :images
has_many :links
etc
Class Quote < ActiveRecord::Base
belongs_to :blog
end
Class Image < ActiveRecord::Base
belongs_to :blog
etc
还是我必须使用多态关联?如果是这样,它会是什么样子?如果无所谓,每种方法的优缺点是什么?