1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

[ActiveStorage] Rewrite Blob.unattached scope code using where.missing

This commit is contained in:
fatkodima 2020-05-04 01:01:30 +03:00
parent 4c724df058
commit a1d960290d

View file

@ -46,7 +46,7 @@ class ActiveStorage::Blob < ActiveRecord::Base
has_many :attachments
scope :unattached, -> { left_joins(:attachments).where(ActiveStorage::Attachment.table_name => { blob_id: nil }) }
scope :unattached, -> { where.missing(:attachments) }
after_initialize do
self.service_name ||= self.class.service.name