Multiple foreign keys referencing the same table in RoR

前端 未结 5 1380
隐瞒了意图╮
隐瞒了意图╮ 2020-12-12 14:13

I want a Customer to reference two Address models, one for the billing address and one for the shipping address. As I understand it, the foreign key is determined by its na

5条回答
  •  鱼传尺愫
    2020-12-12 14:53

    I had the same problem and solved doing this:

    create_table :customers do |t|
      t.integer :address_id, :references => "address"
      t.integer :address_id_1, :references => "address"
      # other attributes not shown
    end
    

提交回复
热议问题