From f4fbc2c1f943ff11776b2c7c34df6bcbe655a4e5 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Tue, 13 Jul 2010 15:30:23 -0400 Subject: update_attributes and update_attributes! are now wrapped in a transaction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#922 state:resovled] Signed-off-by: José Valim --- activerecord/lib/active_record/persistence.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index e53cc5ee8c..3681a63e03 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -121,15 +121,19 @@ module ActiveRecord # Updates all the attributes from the passed-in Hash and saves the record. # If the object is invalid, the saving will fail and false will be returned. def update_attributes(attributes) - self.attributes = attributes - save + with_transaction_returning_status do + self.attributes = attributes + save + end end # Updates an object just like Base.update_attributes but calls save! instead # of save so an exception is raised if the record is invalid. def update_attributes!(attributes) - self.attributes = attributes - save! + with_transaction_returning_status do + self.attributes = attributes + save! + end end # Initializes +attribute+ to zero if +nil+ and adds the value passed as +by+ (default is 1). -- cgit v1.2.3