Module: Katalyst::Content::DuplicatesAttachments
- Extended by:
- ActiveSupport::Concern
- Included in:
- Item
- Defined in:
- app/models/concerns/katalyst/content/duplicates_attachments.rb
Overview
Copies ActiveStorage attachments when a record is duplicated, e.g. for copy-on-write. Pending changes on the source are carried over: new uploads are copied to the duplicate, while attachments that are being removed (either by assigning "" as govuk_attachment_field does, or via nested attributes with _destroy) are dropped from the duplicate.
Defined Under Namespace
Constant Summary collapse
Instance Method Summary collapse
Instance Method Details
#initialize_dup(source) ⇒ Object
13 14 15 16 17 18 19 |
# File 'app/models/concerns/katalyst/content/duplicates_attachments.rb', line 13 def initialize_dup(source) super self.class..each do |reflection| DUPLICATORS.fetch(reflection.macro).new(reflection.name).apply(source, self) end end |