Skip to content

Instantly share code, notes, and snippets.

@bogdanRada
Forked from mihaic195/sql_query.rb
Created February 25, 2022 11:05
Show Gist options
  • Select an option

  • Save bogdanRada/a03b573e8f5804cb3c085a9b1fb2efbe to your computer and use it in GitHub Desktop.

Select an option

Save bogdanRada/a03b573e8f5804cb3c085a9b1fb2efbe 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