diff options
author | Xavier Noria <fxn@hashref.com> | 2008-05-13 00:46:57 +0200 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-05-12 17:04:17 -0700 |
commit | 593e21d6aedcc05d744be4996bd7180edce57efe (patch) | |
tree | 27cb4e5dbaab49554d2a5bde9971a5c9c6521c88 /activerecord/lib | |
parent | a425cd147363a0e8d7e17177ef252dd760197f15 (diff) | |
download | rails-593e21d6aedcc05d744be4996bd7180edce57efe.tar.gz rails-593e21d6aedcc05d744be4996bd7180edce57efe.tar.bz2 rails-593e21d6aedcc05d744be4996bd7180edce57efe.zip |
Dirty attributes aren't cleared if save fails. [#174 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/dirty.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/dirty.rb b/activerecord/lib/active_record/dirty.rb index c6d89e3a05..6034963811 100644 --- a/activerecord/lib/active_record/dirty.rb +++ b/activerecord/lib/active_record/dirty.rb @@ -69,19 +69,19 @@ module ActiveRecord changed.inject({}) { |h, attr| h[attr] = attribute_change(attr); h } end - - # Clear changed attributes after they are saved. + # Attempts to +save+ the record and clears changed attributes if successful. def save_with_dirty(*args) #:nodoc: - save_without_dirty(*args) - ensure - changed_attributes.clear + if status = save_without_dirty(*args) + changed_attributes.clear + end + status end - # Clear changed attributes after they are saved. + # Attempts to <tt>save!</tt> the record and clears changed attributes if successful. def save_with_dirty!(*args) #:nodoc: - save_without_dirty!(*args) - ensure + status = save_without_dirty!(*args) changed_attributes.clear + status end private |