📜  rails on_delete 级联不起作用 - Ruby 代码示例

📅  最后修改于: 2022-03-11 15:04:46.384000             🧑  作者: Mango

代码示例1
// dont do a foreing_key, instead use t.references
class CreateDocumentImages < ActiveRecord::Migration[5.1]
  def change
    create_table :document_images do |t|
      t.references :document, foreign_key: { on_delete: :cascade }
      t.references :image, foreign_key: { on_delete: :cascade}
      t.timestamps
    end
  end
end