From 3565f4c8cfaad642ee747e165d37624cc651d514 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 24 Oct 2013 13:35:21 +1100 Subject: [PATCH] correct monkey patch, disable it from rails4 mode (that has a proper implementation) --- lib/freedom_patches/active_record_base.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/freedom_patches/active_record_base.rb b/lib/freedom_patches/active_record_base.rb index f114315f89d..d4f8f2467c1 100644 --- a/lib/freedom_patches/active_record_base.rb +++ b/lib/freedom_patches/active_record_base.rb @@ -11,10 +11,18 @@ class ActiveRecord::Base exec_sql(*args).cmd_tuples end - # note: update_attributes still spins up a transaction this can cause contention - # this method performs the raw update sidestepping the locking - def update_columns(hash) - self.class.where(self.class.primary_key => self.id).update_all(hash) + # exists fine in rails4 + unless rails4? + # note: update_attributes still spins up a transaction this can cause contention + # this method performs the raw update sidestepping the locking + # exists in rails 4 + def update_columns(hash) + self.class.where(self.class.primary_key => self.id).update_all(hash) + + hash.each do |k,v| + raw_write_attribute k, v + end + end end def exec_sql(*args)