From 8f3d57c0aec4191521b96480c3d2a72392fedfe5 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 6 Jul 2015 08:22:17 +0200 Subject: [PATCH] Added ActiveRecord::Base.transaction to speed up. --- lib/models.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/models.rb b/lib/models.rb index da33b308f..23adfdc1c 100644 --- a/lib/models.rb +++ b/lib/models.rb @@ -173,7 +173,7 @@ returns merge model references to other model - result = Models.merge('User', 2, 4711) + result = Models.merge('User', 2, 4711) # Object, object_id_of_primary, object_id_which_should_be_merged returns @@ -209,9 +209,11 @@ returns } # update items - items_to_update.each {|_id, item| - item.save - } + ActiveRecord::Base.transaction do + items_to_update.each {|_id, item| + item.save + } + end } true end