Module: TrackChanges::ActiveRecord

Defined in:
lib/track_changes/active_record.rb

Instance Method Summary collapse

Instance Method Details

#track_changesObject

Enables auditing of all changes to an ActiveRecord model. Sets up an around filter that will create an Audit for the models changes attribute.

In addition, this will also define a attr_accessor for current_user.



9
10
11
12
13
14
15
16
17
18
# File 'lib/track_changes/active_record.rb', line 9

def track_changes
  send :include, TrackChanges::CurrentUser
  send :include, TrackChanges::Changes

  self.class_eval do
    has_many :audits, :as => :audited

    around_update TrackChanges::AroundUpdate
  end
end