From a4abfa0b6e25fabc16ed8215847752e9a3df19e7 Mon Sep 17 00:00:00 2001 From: BoHung Chiu Date: Sat, 18 Mar 2023 16:26:17 +0800 Subject: [PATCH] Fix bug. --- app/models/seminar_main.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/seminar_main.rb b/app/models/seminar_main.rb index c3e4315..b77d129 100644 --- a/app/models/seminar_main.rb +++ b/app/models/seminar_main.rb @@ -460,6 +460,7 @@ class SeminarMain end end def clone_new_for_object(object,clone_target=nil,clone_mode=false) + @except_clone_relations ||= self.except_clone_relations if clone_mode new_object = object clone_target = object.class.find(object.copy_id) rescue nil if clone_target.nil? @@ -467,7 +468,7 @@ class SeminarMain clone_target = object if clone_target.nil? new_object = object.dup end - return if self.except_clone_relations.to_s.include?(new_object.class.to_s.underscore) + return if @except_clone_relations.to_s.include?(new_object.class.to_s.underscore) @records_all["#{new_object.class.to_s.underscore.singularize}_ids"] = {} if @records_all["#{new_object.class.to_s.underscore.singularize}_ids"].nil? begin @records_all["#{new_object.class.to_s.underscore.singularize}_ids"][clone_target.id] = object.id @@ -585,7 +586,7 @@ class SeminarMain new_object.send("#{f}_id=",(@records_all["#{f}_ids"][clone_target.send("#{f}_id")])) end elsif clone_target.relations[f].macro == :has_one - next if self.except_clone_relations.to_s.include?(f) + next if @except_clone_relations.to_s.include?(f) need_clone_relation = clone_target.send(f) clone_relation = new_object.send(f) clone_relation, need_clone_relation = clone_new_for_object(need_clone_relation.dup, need_clone_relation, true) if clone_relation.nil? @@ -611,7 +612,7 @@ class SeminarMain end new_object.send("#{f}=",clone_relation) elsif clone_target.relations[f].macro == :has_many || clone_target.relations[f].macro == :has_and_belongs_to_many - next if self.except_clone_relations.to_s.include?(f) + next if @except_clone_relations.to_s.include?(f) clone_relations = [] need_clone_relations = clone_target.send(f).asc(:_id).to_a file_flag = false