Sha256: 382218aaa704c9ca6502206b25dc6ff374232fb9bbf3da3166256c587bc981ea
Contents?: true
Size: 763 Bytes
Versions: 13
Compression:
Stored size: 763 Bytes
Contents
# frozen_string_literal: true module Decidim module Pages # Command that gets called whenever a component's page has to be duplicated. # It is 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
13 entries across 13 versions & 1 rubygems