aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/persistence.rb
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-07-13 15:30:23 -0400
committerJosé Valim <jose.valim@gmail.com>2010-07-13 22:02:00 +0200
commitf4fbc2c1f943ff11776b2c7c34df6bcbe655a4e5 (patch)
treeebea9bbac11869cf70391f4521d052d2145d6c38 /activerecord/lib/active_record/persistence.rb
parente35e6171bb27c26b13469ccf188c25bb324e38ab (diff)
downloadrails-f4fbc2c1f943ff11776b2c7c34df6bcbe655a4e5.tar.gz
rails-f4fbc2c1f943ff11776b2c7c34df6bcbe655a4e5.tar.bz2
rails-f4fbc2c1f943ff11776b2c7c34df6bcbe655a4e5.zip
update_attributes and update_attributes! are now wrapped in a transaction
[#922 state:resovled] Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r--activerecord/lib/active_record/persistence.rb12
1 files changed, 8 insertions, 4 deletions
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).