mirror of https://github.com/rails/rails
Merge pull request #44574 from NobodysNightmare/fix-activestorage-cdn-example
Fix the example for using a CDN with ActiveStorage
This commit is contained in:
commit
f3e176c23b
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue