Module: Alchemy::Page::PageElements::ClassMethods
- Defined in:
- app/models/alchemy/page/page_elements.rb
Instance Method Summary collapse
-
#copy_elements(source, target) ⇒ Array
Copy page elements.
Instance Method Details
#copy_elements(source, target) ⇒ Array
Copy page elements
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/alchemy/page/page_elements.rb', line 29 def copy_elements(source, target) new_elements = [] source.elements.not_trashed.each do |element| # detect cell for element if element.cell cell = target.cells.detect { |c| c.name == element.cell.name } else cell = nil end # if cell is nil also pass nil to element.cell_id new_element = Element.copy(element, :page_id => target.id, :cell_id => (cell.blank? ? nil : cell.id)) # move element to bottom of the list new_element.move_to_bottom new_elements << new_element end new_elements end |