app/controllers/extensions_controller.rb
#
# GET /extensions/:id/download
#
# Redirects to the download location for the latest version of this extension.
#
GET /extensions/:id/download
Redirects to the download location for the latest version of this extension.
GET / extensions / : id / download Redirects to the download location for the latest version of this extension .
def download
    extension = Extension.with_owner_and_lowercase_name(owner_name: params[:username], lowercase_name: params[:id])
    latest_version = extension.latest_extension_version
    if latest_version.present?
      BonsaiAssetIndex::Metrics.increment('extension.downloads.web')
      DailyMetric.increment(latest_version.download_daily_metric_key)
      redirect_to extension_version_download_url(extension, latest_version, username: params[:username])
    else
      redirect_to(
        owner_scoped_extension_url(extension),
        notice: t(
          'download.not_found',
          extension_or_tool: extension.name
        )
      )
    end
  end
def download extension = Extension . with_owner_and_lowercase_name ( owner_name : params [ :username ] , lowercase_name : params [ :id ] ) latest_version = extension . latest_extension_version if latest_version . present? BonsaiAssetIndex :: Metrics . increment ( 'extension.downloads.web' ) DailyMetric . increment ( latest_version . download_daily_metric_key ) redirect_to extension_version_download_url ( extension , latest_version , username : params [ :username ] ) else redirect_to ( owner_scoped_extension_url ( extension ) , notice : t ( 'download.not_found' , extension_or_tool : extension . name ) ) end end
GET /extensions/:id/download
Redirects to the download location for the latest version of this extension.
GET / extensions / : id / download Redirects to the download location for the latest version of this extension .