Skip to content

Instantly share code, notes, and snippets.

@mihaic195
Created September 3, 2019 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mihaic195/63f60f08311f69996411a261c151a662 to your computer and use it in GitHub Desktop.
Save mihaic195/63f60f08311f69996411a261c151a662 to your computer and use it in GitHub Desktop.
Blob observer
class BlobObserver < ActiveRecord::Observer
observe ActiveStorage::Blob
def after_save(blob)
blob.update_columns(storage_url: "https://s3-#{ENV['AWS_AS_S3_REGION']}.amazonaws.com/#{ENV['AWS_AS_S3_BUCKET']}/" + blob.key)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment