Fix platform clone. Refs #207

This commit is contained in:
Pavel Chipiga 2012-06-08 20:37:16 +03:00
parent 26299c234b
commit a2c14313ed
3 changed files with 8 additions and 9 deletions

View File

@ -104,11 +104,10 @@ class Platform < ActiveRecord::Base
end
def base_clone(attrs = {}) # :description, :name, :owner
clone.tap do |c|
# c.attributes = attrs #
attrs.each {|k,v| c.send("#{k}=", v)}
c.updated_at = nil; c.created_at = nil # :id = nil
c.parent = self
dup.tap do |c|
attrs.each {|k,v| c.send("#{k}=", v)} # c.attributes = attrs
c.updated_at = nil; c.created_at = nil
c.parent = self; c.released = false
end
end

View File

@ -54,10 +54,10 @@ class Product < ActiveRecord::Base
end
def full_clone(attrs = {})
clone.tap do |c| # dup
dup.tap do |c|
c.platform_id = nil
attrs.each {|k,v| c.send("#{k}=", v)}
c.updated_at = nil; c.created_at = nil # :id = nil
c.updated_at = nil; c.created_at = nil
end
end

View File

@ -17,10 +17,10 @@ class Repository < ActiveRecord::Base
attr_readonly :name, :platform_id
def base_clone(attrs = {})
clone.tap do |c| # dup
dup.tap do |c|
c.platform_id = nil
attrs.each {|k,v| c.send("#{k}=", v)}
c.updated_at = nil; c.created_at = nil # :id = nil
c.updated_at = nil; c.created_at = nil
end
end