aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/dirty.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/dirty.rb')
-rw-r--r--activerecord/lib/active_record/dirty.rb16
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