Merge pull request #44574 from NobodysNightmare/fix-activestorage-cdn-example

Fix the example for using a CDN with ActiveStorage
This commit is contained in:
Vipul A M 2022-04-05 15:39:22 -04:00 committed by GitHub
commit f3e176c23b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -645,15 +645,17 @@ You should also make sure that the generated URLs use the CDN host instead of yo
```ruby
# config/routes.rb
direct :cdn_image do |model, options|
expires_in = options.delete(:expires_in) { ActiveStorage.urls_expire_in }
if model.respond_to?(:signed_id)
route_for(
:rails_service_blob_proxy,
model.signed_id,
model.signed_id(expires_in: expires_in),
model.filename,
options.merge(host: ENV['CDN_HOST'])
)
else
signed_blob_id = model.blob.signed_id
signed_blob_id = model.blob.signed_id(expires_in: expires_in)
variation_key = model.variation.key
filename = model.blob.filename