Created
September 3, 2019 14:09
-
-
Save mihaic195/63f60f08311f69996411a261c151a662 to your computer and use it in GitHub Desktop.
Blob observer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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