Skip to content

Commit 3757222

Browse files
authored
Merge pull request rails#39136 from fatkodima/active_storage-unattached-missing
[ActiveStorage] Rewrite Blob.unattached scope code using where.missing
2 parents 4c724df + a1d9602 commit 3757222

File tree

1 file changed

+1
-1
lines changed
  • activestorage/app/models/active_storage

1 file changed

+1
-1
lines changed

activestorage/app/models/active_storage/blob.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ActiveStorage::Blob < ActiveRecord::Base
4646

4747
has_many :attachments
4848

49-
scope :unattached, -> { left_joins(:attachments).where(ActiveStorage::Attachment.table_name => { blob_id: nil }) }
49+
scope :unattached, -> { where.missing(:attachments) }
5050

5151
after_initialize do
5252
self.service_name ||= self.class.service.name

0 commit comments

Comments
 (0)