AgileVentures / AgileVentures/MetPlus_tracker

Address delete bug

Open
#722 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
No language data
Stars
2
Forks
5
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.