diff options
author | fatkodima <fatkodima123@gmail.com> | 2018-02-12 22:09:52 +0200 |
---|---|---|
committer | fatkodima <fatkodima123@gmail.com> | 2018-02-12 22:13:00 +0200 |
commit | 0c463f50eaf939042ea9561eed85146612daab5e (patch) | |
tree | 2cb9aff65b571af6c35e2fbbef014bb8f8acfa7d /activestorage/app/models | |
parent | 18b13d768fc1ecb8a209c9b1d3c1ddcfe27e3737 (diff) | |
download | rails-0c463f50eaf939042ea9561eed85146612daab5e.tar.gz rails-0c463f50eaf939042ea9561eed85146612daab5e.tar.bz2 rails-0c463f50eaf939042ea9561eed85146612daab5e.zip |
Add ActiveStorage::Blob.unattached scope
Diffstat (limited to 'activestorage/app/models')
-rw-r--r-- | activestorage/app/models/active_storage/blob.rb | 2 |
1 files changed, 2 insertions, 0 deletions
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 |