From 0772880bbc0b18a78d8dacd56aeaa5bee334608a Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Mon, 5 Oct 2026 11:53:57 +0300 Subject: [PATCH] download dynamic document --- app/controllers/template_documents_controller.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/controllers/template_documents_controller.rb b/app/controllers/template_documents_controller.rb index fafa6c141..6aa95da02 100644 --- a/app/controllers/template_documents_controller.rb +++ b/app/controllers/template_documents_controller.rb @@ -6,7 +6,17 @@ class TemplateDocumentsController < ApplicationController FILES_TTL = 5.minutes def index - render json: @template.schema_documents.map { |d| ActiveStorage::Blob.proxy_path(d.blob, expires_at: FILES_TTL.from_now.to_i) } + documents = @template.schema.map do |item| + if item['dynamic'] + dynamic_document = @template.schema_dynamic_documents.find { |e| e.uuid == item['attachment_uuid'] } + + DynamicDocuments::EnsureVersionGenerated.call(dynamic_document).document_attachment + else + @template.schema_documents.find { |e| e.uuid == item['attachment_uuid'] } + end + end + + render json: documents.map { |d| ActiveStorage::Blob.proxy_path(d.blob, expires_at: FILES_TTL.from_now.to_i) } end def create