Class: Testimonials::MediaController

Inherits:
ApplicationController show all
Defined in:
app/controllers/testimonials/media_controller.rb

Overview

Hands out video and avatar files by testimonial id, so consumers never need to know about Active Storage. Admins can fetch anything; everyone else only reaches media of publishable (approved + consented) testimonials, and only when the read API is public. The actual bytes are served by Active Storage's own controllers (signed, expiring URLs, with Range support — video elements need that).

Instance Method Summary collapse

Instance Method Details

#avatarObject



26
27
28
29
30
# File 'app/controllers/testimonials/media_controller.rb', line 26

def avatar
  head :not_found and return unless @testimonial.avatar_attached?

  redirect_to main_app.rails_blob_path(@testimonial.avatar, disposition: disposition)
end

#posterObject



20
21
22
23
24
# File 'app/controllers/testimonials/media_controller.rb', line 20

def poster
  head :not_found and return unless @testimonial.poster_attached?

  redirect_to main_app.rails_blob_path(@testimonial.poster, disposition: disposition)
end

#videoObject



14
15
16
17
18
# File 'app/controllers/testimonials/media_controller.rb', line 14

def video
  head :not_found and return unless @testimonial.video_attached?

  redirect_to main_app.rails_blob_path(@testimonial.video_file, disposition: disposition)
end