Skip to content

Instantly share code, notes, and snippets.

@mihaic195
Created September 10, 2019 09:23
Show Gist options
  • Save mihaic195/1aed3eb8b45be6b59af44c0185d5cc88 to your computer and use it in GitHub Desktop.
Save mihaic195/1aed3eb8b45be6b59af44c0185d5cc88 to your computer and use it in GitHub Desktop.
Simple sql query for extracting the direct URL of an attachment
SELECT blobs.storage_url
FROM active_storage_blobs AS blobs
INNER JOIN active_storage_attachments AS attachments ON attachments.blob_id = blobs.id
WHERE attachments.record_type = 'Model1'
AND attachments.name = 'logo'
LIMIT 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment