def clone_habtm(old_object, new_object)
      old_object.class.reflect_on_all_associations.select{|a| a.macro == :has_and_belongs_to_many}.each do |association|
        method_ids = "#{association.name.to_s.singularize.to_sym}_ids"
        new_object.send(:"#{method_ids}=", old_object.send(method_ids))
      end

      new_object
    end
def clone_habtm(old_object, new_object)
      old_object.class.reflect_on_all_associations.select{|a| a.macro == :has_and_belongs_to_many}.each do |association|
        method_ids = "#{association.name.to_s.singularize.to_sym}_ids"
        new_object.send(:"#{method_ids}=", old_object.send(method_ids))
      end

      new_object
    end
clone has_and_belongs_to_many associtations