Polymorphic Association with multiple associations on the same model

前端 未结 2 1400
长情又很酷
长情又很酷 2020-12-28 22:40

I\'m slightly confused about a polymorphic association I\'ve got. I need an Article model to have a header image, and many images, but I want to have a single Image model. T

2条回答
  •  被撕碎了的回忆
    2020-12-28 23:01

    I tried this, but then header_image returns one of the images. Simply because the images table doesn't specify a different image use type (header_image vs. normal image). It simply says: imageable_type = Image for both uses. So if there's no information stored about the use type, ActiveRecord cannot differentiate.

提交回复
热议问题