rubyforgood / rubyforgood/awbw

Writes that skip callbacks leave no event: update_all, update_columns, dependent: :nullify

Open
#2,357 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Ruby
Stars
15
Forks
26
Avg merge
12h 42m
Merged PRs (30d)
242

Description

🤖 From Claude:

AhoyTrackable hangs off after_create / after_update / after_destroy, so any write that bypasses callbacks is invisible. Distinct from #2351 (which is about who is acting) — here the callback never runs at all.

Where it bites

dependent: :nullify is an update_all. Destroying a parent silently rewrites its children:

  • destroying an EventRegistration re-points its notifications and affiliations
  • destroying a FormField orphans every form_answer
  • destroying an Address nullifies the affiliations pointing at it

The destroy of the parent is recorded. The rewrite of the children isn't, so the children's history shows nothing where the data changed under them.

Direct column writes:

  • SectorsTaggable resets the primary flag with update_all (sectors_taggable.rb:52)
  • Affiliation syncs org columns with update_columns (affiliation.rb:191)
  • story_share_admin_controller reorders with update_columns

Recommendation

Don't chase every call — most are deliberate (that's why they skip callbacks). Fix the ones where the silence misleads:

  1. Registration transfer / deletion — the affiliation and notification re-pointing is exactly the kind of thing an admin later asks about.
  2. Form field deletion — answers changing shape without a trace is a data-integrity story, not just an audit one.

For those, either record an explicit event where the write happens, or replace the bulk write with per-record saves where the volume is small enough (it is, in both cases).

Acceptance

Destroying a registration leaves a record of what happened to its affiliations and notifications — either on their own history or on the registration's.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the dependent associations for EventRegistration and FormField, then inspect the cited write sites: sectors_taggable.rb:52, affiliation.rb:191, and story_share_admin_controller. Trace how history events are recorded around registration deletion and form-field deletion. Done means destroying a registration records the resulting affiliation and notification changes, with the form-field case also leaving a trace.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.