module TrackChanges::Model::Base
Public Instance Methods
tracks_changes(options = {})
click to toggle source
# File lib/track_changes/model.rb, line 4 def tracks_changes(options = {}) extend ClassMethods include InstanceMethods class_attribute :track_changes_options self.track_changes_options = options attr_accessor :track_changes # Faux attribute to allow disabling of change tracking on this record attr_writer :track_changes_by # Faux attribute to store who made the changes so we can save it in the diff has_one :snapshot, :as => :record, :class_name => 'TrackChanges::Snapshot' # A representation of this record as it was last saved has_many :diffs, lambda { reorder('id DESC') }, :as => :record, :class_name => 'TrackChanges::Diff' # A representation of changes made between saves through this record's lifetime after_save :persist_tracked_changes end