mirror of https://github.com/docusealco/docuseal
parent
02fee9f885
commit
866bf7291d
|
After Width: | Height: | Size: 450 B |
|
After Width: | Height: | Size: 378 B |
@ -0,0 +1,27 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Templates
|
||||||
|
module CloneAttachments
|
||||||
|
module_function
|
||||||
|
|
||||||
|
def call(template:, original_template:)
|
||||||
|
original_template.documents.each do |document|
|
||||||
|
new_document = ActiveStorage::Attachment.create!(
|
||||||
|
uuid: document.uuid,
|
||||||
|
blob_id: document.blob_id,
|
||||||
|
name: 'documents',
|
||||||
|
record: template
|
||||||
|
)
|
||||||
|
|
||||||
|
document.preview_images_attachments.each do |preview_image|
|
||||||
|
ActiveStorage::Attachment.create!(
|
||||||
|
uuid: preview_image.uuid,
|
||||||
|
blob_id: preview_image.blob_id,
|
||||||
|
name: 'preview_images',
|
||||||
|
record: new_document
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in new issue