instance method service_url

Ruby on Rails 5.2.8.1

Since v5.2.8.1 Last seen in v6.1.7.10

Available in: v5.2.8.1 v6.0.6 v6.1.7.10

Signature

service_url(expires_in: service.url_expires_in, disposition: :inline)

Returns the URL of the variant on the service. This URL is intended to be short-lived for security and not used directly with users. Instead, the service_url should only be exposed as a redirect from a stable, possibly authenticated URL. Hiding the service_url behind a redirect also gives you the power to change services without updating all URLs. And it allows permanent URLs that redirect to the service_url to be cached in the view.

Use url_for(variant) (or the implied form, like +link_to variant+ or +redirect_to variant+) to get the stable URL for a variant that points to the ActiveStorage::RepresentationsController, which in turn will use this service_call method for its redirection.

Parameters

expires_in key = service.url_expires_in
disposition key = :inline
Source
# File activestorage/app/models/active_storage/variant.rb, line 70
  def service_url(expires_in: service.url_expires_in, disposition: :inline)
    service.url key, expires_in: expires_in, disposition: disposition, filename: filename, content_type: content_type
  end

Defined in activestorage/app/models/active_storage/variant.rb line 70 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveStorage::Variant

Type at least 2 characters to search.

↑↓ navigate · open · esc close