Module: Collavre::PublicAssetsHelper
- Defined in:
- app/helpers/collavre/public_assets_helper.rb
Instance Method Summary collapse
-
#public_asset_url(blob) ⇒ Object
Returns a URL for serving an ActiveStorage blob through the public-assets proxy.
Instance Method Details
#public_asset_url(blob) ⇒ Object
Returns a URL for serving an ActiveStorage blob through the public-assets proxy. When PUBLIC_ASSETS_HOST is set (e.g. CloudFront domain) the URL is absolute; otherwise relative so the browser uses the current host.
8 9 10 11 12 |
# File 'app/helpers/collavre/public_assets_helper.rb', line 8 def public_asset_url(blob) path = "/public-assets/blobs/#{blob.signed_id}/#{blob.filename.sanitized}" host = Collavre::IntegrationSettings.fetch(:public_assets_host) host ? "#{host.chomp('/')}#{path}" : path end |