Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Ensure that the `_blob` association is properly loaded when attaching `::One` #35412
I had first added these changes into a separate commit on #35390.
Consider a model with
class User < ActiveRecord::Base has_one_attached :avatar has_many_attached :highlights end
user.avatar.attach(blob) user.avatar_attachment.present? => true user.avatar_blob.present? => false # Incorrect!
This is a false negative. It happens because after the attachment and blob
In reality, the blob does in fact exist. We can verify this as follows:
user.avatar.attach(blob) user.avatar_attachment.blob.present? => true # Blob does exist!
The fix in this change is to simply assign the
user.avatar.attach(blob) user.avatar_attachment.present? => true user.avatar_blob.present? => true # Woohoo!
We don't see this issue with
user.highlights.attach(blob) user.highlights_attachments.any? => true user.highlights_blobs.any? => true