Skip to content

Fix broken background image after removal#2817

Merged
flavorjones merged 1 commit intomainfrom
broken-background-image
Apr 9, 2026
Merged

Fix broken background image after removal#2817
flavorjones merged 1 commit intomainfrom
broken-background-image

Conversation

@flavorjones
Copy link
Copy Markdown
Member

@flavorjones flavorjones commented Apr 8, 2026

Summary

  • Removing a card's background image left a dead blob URL (404) because the fragment cache was never invalidated
  • Root cause: ActiveStorage::Record and ApplicationRecord used separate connection pools (from separate connects_to calls), so belongs_to touch: true on attachments silently failed — the card couldn't join the attachment's transaction to receive the deferred touch
  • Fix: delegate connection_pool from ActiveStorage::Record to ApplicationRecord so they share a single pool, and the existing touch: true mechanism works as intended

Test plan

  • Added model-level tests verifying purge and purge_later touch the card's updated_at
  • Full test suite passes (1593 tests, 0 failures)
  • Verify in development: add a background image to a card, remove it, confirm the image disappears on redirect without a 404 in the console

Copilot AI review requested due to automatic review settings April 8, 2026 21:37

This comment was marked as outdated.

@flavorjones flavorjones force-pushed the broken-background-image branch from 050660b to bdea68f Compare April 8, 2026 21:50
@flavorjones

This comment was marked as outdated.

@flavorjones flavorjones force-pushed the broken-background-image branch from bdea68f to 0f1ec73 Compare April 9, 2026 15:27
Copilot AI review requested due to automatic review settings April 9, 2026 15:27
@flavorjones flavorjones changed the title Fix broken background image after removal by touching record on purge Fix broken background image after removal Apr 9, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ActiveStorage::Record and ApplicationRecord used separate connection
pools (from separate `connects_to` calls). This meant `belongs_to
touch: true` on attachments silently failed — the card couldn't join the
attachment's transaction to receive the deferred touch, so fragment
caches were never invalidated after image removal.

Fix by delegating `connection_pool` from ActiveStorage::Record to
ApplicationRecord so they share a single pool.
@flavorjones flavorjones force-pushed the broken-background-image branch from 0f1ec73 to 03a3576 Compare April 9, 2026 16:20
@flavorjones
Copy link
Copy Markdown
Member Author

Tested in staging, looks good.

@flavorjones flavorjones merged commit b07f592 into main Apr 9, 2026
13 checks passed
@flavorjones flavorjones deleted the broken-background-image branch April 9, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants