Closed mo-nathan closed 3 months ago
Actually, check_for_broken_references looks for belongs_to reflections. For example, field slips must belong to a project and a user? (Sorry, I've been out doing fieldwork and haven't been able to keep up with your recent work on field slips!)
At some point in the relatively recent past Nimmo added all of the missing associations for all of the other models. He can probably provide a better defense of the policy. But I think they are pretty lazy these days, and if they aren't used, they incur very little cost.
But if you would prefer, feel free to alter check_for_broken_references. I think all we'd need to do is add these two associations to the reflections hash around lines 26-40, since they won't be picked up automatically by searching for belongs_to relationships. My intent here was to make it automatically pick up new associations without requiring us to remember to do anything.
On Sun, Mar 31, 2024 at 4:53 PM Nathan Wilson @.***> wrote:
I think this is what is now wanted. I guess this makes sense. Seems a bit like unnecessary overhead to me.
You can view, comment on, or merge this pull request online at:
https://github.com/MushroomObserver/mushroom-observer/pull/2083 Commit Summary
- 6174001 https://github.com/MushroomObserver/mushroom-observer/pull/2083/commits/6174001419e9c656ed93278228481f161215ff3a Fix MISSING REFLECTIONS
File Changes
(3 files https://github.com/MushroomObserver/mushroom-observer/pull/2083/files)
- M app/models/project.rb https://github.com/MushroomObserver/mushroom-observer/pull/2083/files#diff-611e7045e8b0212d101cd856c335296959519af63b80129f51c246a7bbfe7b91 (1)
- M app/models/user.rb https://github.com/MushroomObserver/mushroom-observer/pull/2083/files#diff-9802ca3c9c4cf89904fd44bc114e35ebdf2c5dd3d5b645491e2b253e1afef29b (1)
- M script/check_for_broken_references https://github.com/MushroomObserver/mushroom-observer/pull/2083/files#diff-d0e2880c173d7bf9b32337714f4ab5cf8bdcd911c7ec973da02b89415f687f9a (3)
Patch Links:
- https://github.com/MushroomObserver/mushroom-observer/pull/2083.patch
- https://github.com/MushroomObserver/mushroom-observer/pull/2083.diff
— Reply to this email directly, view it on GitHub https://github.com/MushroomObserver/mushroom-observer/pull/2083, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYTNNKRSTDVPKJ2EYBOXSLY3BZWBAVCNFSM6AAAAABFQWITS6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGIYTOMJXHA2TOMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>
It already had the belongs_to relationships. I added the corresponding has_manys (although nothing uses them), but that didn't fix the issue. I finally got them to go away by adding the rows to script/check_for_broken_references. I don't understand the purpose here well enough to have more opinion about it.
@JoeCohen Thanks for pointing that case out. I think I've fixed it up so it will work better in that case. As you suggest I would want the field slip to continue to work.
I think this is what is now wanted. I guess this makes sense. Seems a bit like unnecessary overhead to me.