Fix bug. #10
			
				
			
		
		
		
	| 
						 | 
					@ -460,6 +460,7 @@ class SeminarMain
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  def clone_new_for_object(object,clone_target=nil,clone_mode=false)
 | 
					  def clone_new_for_object(object,clone_target=nil,clone_mode=false)
 | 
				
			||||||
 | 
					    @except_clone_relations ||= self.except_clone_relations
 | 
				
			||||||
    if clone_mode
 | 
					    if clone_mode
 | 
				
			||||||
      new_object = object
 | 
					      new_object = object
 | 
				
			||||||
      clone_target = object.class.find(object.copy_id) rescue nil if clone_target.nil?
 | 
					      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?
 | 
					      clone_target = object if clone_target.nil?
 | 
				
			||||||
      new_object = object.dup
 | 
					      new_object = object.dup
 | 
				
			||||||
    end
 | 
					    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?
 | 
					    @records_all["#{new_object.class.to_s.underscore.singularize}_ids"] = {} if @records_all["#{new_object.class.to_s.underscore.singularize}_ids"].nil?
 | 
				
			||||||
    begin
 | 
					    begin
 | 
				
			||||||
      @records_all["#{new_object.class.to_s.underscore.singularize}_ids"][clone_target.id] = object.id
 | 
					      @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")]))
 | 
					            new_object.send("#{f}_id=",(@records_all["#{f}_ids"][clone_target.send("#{f}_id")]))
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
        elsif clone_target.relations[f].macro == :has_one
 | 
					        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)
 | 
					          need_clone_relation = clone_target.send(f)
 | 
				
			||||||
          clone_relation = new_object.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?
 | 
					          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
 | 
					          end
 | 
				
			||||||
          new_object.send("#{f}=",clone_relation)
 | 
					          new_object.send("#{f}=",clone_relation)
 | 
				
			||||||
        elsif clone_target.relations[f].macro == :has_many || clone_target.relations[f].macro == :has_and_belongs_to_many
 | 
					        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 = []
 | 
					          clone_relations = []
 | 
				
			||||||
          need_clone_relations = clone_target.send(f).asc(:_id).to_a
 | 
					          need_clone_relations = clone_target.send(f).asc(:_id).to_a
 | 
				
			||||||
          file_flag = false
 | 
					          file_flag = false
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue