diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-07-13 15:30:23 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-07-13 22:02:00 +0200 |
commit | f4fbc2c1f943ff11776b2c7c34df6bcbe655a4e5 (patch) | |
tree | ebea9bbac11869cf70391f4521d052d2145d6c38 /activerecord/lib | |
parent | e35e6171bb27c26b13469ccf188c25bb324e38ab (diff) | |
download | rails-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')
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 12 |
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). |