Module: ActiveRecord::AttributeMethods::Dirty

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Dirty, Write
Defined in:
lib/active_record/attribute_methods/dirty.rb

Instance Method Summary collapse

Instance Method Details

#reloadObject

reload the record and clears changed attributes.



43
44
45
46
47
48
# File 'lib/active_record/attribute_methods/dirty.rb', line 43

def reload(*) #:nodoc:
  super.tap do
    @previously_changed.clear
    @changed_attributes.clear
  end
end

#saveObject

Attempts to save the record and clears changed attributes if successful.



21
22
23
24
25
26
27
28
29
# File 'lib/active_record/attribute_methods/dirty.rb', line 21

def save(*) #:nodoc:
  if status = super
    @previously_changed = changes
    @changed_attributes.clear
  elsif IdentityMap.enabled?
    IdentityMap.remove(self)
  end
  status
end

#save!Object

Attempts to save! the record and clears changed attributes if successful.



32
33
34
35
36
37
38
39
40
# File 'lib/active_record/attribute_methods/dirty.rb', line 32

def save!(*) #:nodoc:
  super.tap do
    @previously_changed = changes
    @changed_attributes.clear
  end
rescue
  IdentityMap.remove(self) if IdentityMap.enabled?
  raise
end