AgileVentures / AgileVentures/MetPlus_tracker

Address delete bug

オープン
#722 コメント 2 件 リアクション 0 件 担当者 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 を短くまとめたダイジェスト。