Polymorphic association

后端 未结 3 489
心在旅途
心在旅途 2021-02-06 05:57

If you have polymorphic belongs_to associations then references will add both of the columns required:

create_table :products do |t|
  t.references :attachment,          


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-02-06 06:25

    polymorphic means that it can belong to different objects (or, different records in different tables). The way it determines this is based on the type and id fields. If your association was not polymorphic it would only have an _id field.

提交回复
热议问题