mirror of https://github.com/docusealco/docuseal
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
701 B
28 lines
701 B
# 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
|