From 0c463f50eaf939042ea9561eed85146612daab5e Mon Sep 17 00:00:00 2001 From: fatkodima Date: Mon, 12 Feb 2018 22:09:52 +0200 Subject: Add ActiveStorage::Blob.unattached scope --- activestorage/app/models/active_storage/blob.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activestorage/app') diff --git a/activestorage/app/models/active_storage/blob.rb b/activestorage/app/models/active_storage/blob.rb index bca9f4c590..3bcd7599d0 100644 --- a/activestorage/app/models/active_storage/blob.rb +++ b/activestorage/app/models/active_storage/blob.rb @@ -27,6 +27,8 @@ class ActiveStorage::Blob < ActiveRecord::Base has_many :attachments + scope :unattached, -> { left_joins(:attachments).where(ActiveStorage::Attachment.table_name => { blob_id: nil }) } + class << self # You can used the signed ID of a blob to refer to it on the client side without fear of tampering. # This is particularly helpful for direct uploads where the client-side needs to refer to the blob -- cgit v1.2.3