Class: ProductTours::MediaController

Inherits:
ApplicationController show all
Includes:
ActiveStorage::Streaming
Defined in:
app/controllers/product_tours/media_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



7
8
9
10
11
12
13
14
# File 'app/controllers/product_tours/media_controller.rb', line 7

def show
  tour = Tour.find(params[:id])
  allowed = ProductTours.admin?(request) || (ProductTours.enabled?(request) && tour.published?)
  return head :forbidden unless allowed
  return head :not_found unless tour.uploaded_video?

  stream(tour.video.blob)
end