Why did Rails 5 changed “index” to “foreign key”?

前端 未结 3 722
迷失自我
迷失自我 2021-02-08 06:56

If you had this in Rails 4:

t.references :event, index: true

Now you could use foreign_key instead of index in Rails

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-08 07:12

    foreign_key and index are completely different things (as you may judge from their names).

    So nothing is being changed, you still can use two.

    You can check out these docs for some more info on establishing associations in migrations.

提交回复
热议问题