Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix strict loading for Active Storage previews #50043

Conversation

jonathanhefner
Copy link
Member

ActiveStorage::Preview#url delegates to the preview image's variant, which in turn delegates to the variant's blob. Thus when the variant has already been processed and strict loading is enabled, the association chain of preview_image_attachment => blob => variant_records => image_attachment => blob must be fully pre-loaded; otherwise, ActiveStorage::Preview#url will raise an ActiveRecord::StrictLoadingViolationError.

`ActiveStorage::Preview#url` delegates to the preview image's variant,
which in turn delegates to the variant's blob.  Thus when the variant
has already been processed and strict loading is enabled, the
association chain of `preview_image_attachment` => `blob` =>
`variant_records` => `image_attachment` => `blob` must be fully
pre-loaded; otherwise, `ActiveStorage::Preview#url` will raise an
`ActiveRecord::StrictLoadingViolationError`.
@jonathanhefner jonathanhefner merged commit 55c7b9b into rails:main Nov 13, 2023
4 checks passed
jonathanhefner added a commit that referenced this pull request Nov 14, 2023
…oading-preview-url

Fix strict loading for Active Storage previews

(cherry picked from commit 55c7b9b)
jonathanhefner added a commit that referenced this pull request Nov 14, 2023
…oading-preview-url

Fix strict loading for Active Storage previews

(cherry picked from commit 55c7b9b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant