Class: ActiveStorageDashboard::AttachmentsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/active_storage_dashboard/attachments_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#paginate

Instance Method Details

#downloadObject



27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/active_storage_dashboard/attachments_controller.rb', line 27

def download
  @attachment = ActiveStorage::Attachment.find(params[:id])
  @blob = @attachment.blob
  
  # Pass along the disposition parameter if present
  if params[:disposition].present?
    redirect_to download_blob_path(@blob, disposition: params[:disposition])
  else
    redirect_to download_blob_path(@blob)
  end
end

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/active_storage_dashboard/attachments_controller.rb', line 5

def index
  @attachments = ActiveStorage::Attachment.order(created_at: :desc)
  
  # Get record types for filter dropdown
  @record_types = ActiveStorage::Attachment.distinct.pluck(:record_type).compact.sort
  
  # Get content types for filter dropdown
  @content_types = ActiveStorage::Blob.joins(:attachments).distinct.pluck(:content_type).compact.sort
  
  # Apply filters
  apply_filters
  
  # Pagination after filters
  @total_count = @attachments.count
  @attachments = paginate(@attachments)
end

#showObject



22
23
24
25
# File 'app/controllers/active_storage_dashboard/attachments_controller.rb', line 22

def show
  @attachment = ActiveStorage::Attachment.find(params[:id])
  @blob = @attachment.blob
end