Sha256: 7851364b9c521c85ddc948870c2251865114057c212bd3fd812025f56b396121
Contents?: true
Size: 762 Bytes
Versions: 12
Compression:
Stored size: 762 Bytes
Contents
# frozen_string_literal: true module Decidim module Pages # Command that gets called whenever a component's page has to be duplicated. # It's need a context with the old component that # is going to be duplicated on the new one class CopyPage < Decidim::Command def initialize(context) @context = context end def call Decidim::Pages::Page.transaction do pages = Decidim::Pages::Page.where(component: @context[:old_component]) pages.each do |page| Decidim::Pages::Page.create!(component: @context[:new_component], body: page.body) end end broadcast(:ok) rescue ActiveRecord::RecordInvalid broadcast(:invalid) end end end end
Version data entries
12 entries across 12 versions & 1 rubygems