Module: Alchemy::Page::PageElements::ClassMethods

Defined in:
app/models/alchemy/page/page_elements.rb

Instance Method Summary collapse

Instance Method Details

#copy_elements(source, target) ⇒ Array

Copy page elements

Parameters:

Returns:

  • (Array)

52
53
54
55
56
57
58
59
# File 'app/models/alchemy/page/page_elements.rb', line 52

def copy_elements(source, target)
  source_elements = source.all_elements.not_nested.not_trashed
  source_elements.order(:position).map do |source_element|
    Element.copy(source_element, {
      page_id: target.id,
    }).tap(&:move_to_bottom)
  end
end