Sha256: d2c14b832233b45d637f08939ca783f5fb615a56a0b45c4dd81689e3de4605d7
Contents?: true
Size: 762 Bytes
Versions: 63
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 < Rectify::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
63 entries across 63 versions & 1 rubygems