From a2c14313ed6af294b2d30462b74362c33aec500a Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Fri, 8 Jun 2012 20:37:16 +0300 Subject: [PATCH] Fix platform clone. Refs #207 --- app/models/platform.rb | 9 ++++----- app/models/product.rb | 4 ++-- app/models/repository.rb | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/models/platform.rb b/app/models/platform.rb index bde879c34..27cc90d70 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -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 diff --git a/app/models/product.rb b/app/models/product.rb index 80d4945e4..013ef34b1 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -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 diff --git a/app/models/repository.rb b/app/models/repository.rb index 5318b93ba..2fd58e3f6 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -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