3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/globalize2/compatibility/copy_move/copy_move_model_extensions.rb', line 3
def self.included(base)
base.class_eval do
alias_method :old_copy_to, :copy_to
def copy_to(parent, status = nil)
parent.children.build(copiable_attributes.symbolize_keys.merge(new_slug_and_title_under(parent))).tap do |new_page|
self.translations.each do |gt|
new_page.translations << gt.clone
end
self.parts.each do |part|
new_page.parts << part.clone
end
new_page.status_id = status.blank? ? new_page.status_id : status
new_page.save!
end
end
end
end
|