AgileVentures / AgileVentures/MetPlus_tracker

Address delete bug

未關閉
#722 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
沒有語言資料
星號
2
分支
5
PR 合併指標
30 天內沒有已合併 PR

描述

This exception occurred in production:
```
ERROR: update or delete on table "addresses" violates foreign key constraint "fk_rails_c3132b644e" on table "jobs" DETAIL: Key (id)=(2) is still referenced from table "jobs". : DELETE FROM "addresses" WHERE "addresses"."id" = $1
```
So, an address associated with one or more jobs is being destroyed, and the model associations do not allow for that.

Possible fix - add the following association to the Address model:
```
has_many :jobs, dependent: :nullify
```

Note: the above fixes the address destroy problem in the rails console - that is, destroying an address that is associated with one or more jobs does not raise an exception, and does set the address_id (foreign key in "jobs" table) to `nil`, as the association statement specifies. However, I have not run all tests so confirm that this does not break anything else.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。