我对我所拥有的多态关联感到有些困惑。我需要一个 Article 模型来拥有一个标题图像和许多图像,但我想要一个 Image 模型。更令人困惑的是,Image 模型是多态的(允许其他资源拥有许多图像)。
我在我的文章模型中使用了这个关联:
class Article < ActiveRecord::Base
has_one :header_image, :as => :imageable
has_many :images, :as => :imageable
end
这可能吗?谢谢。