Class: AuditRecord

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/auditable/audit_record.rb

Overview

Schema Information

Table name: audit_records

id             :integer(4)      not null, primary key
user_id        :integer(4)
action         :string(255)
modifications  :text
remote_address :string(255)
auditable_type :string(255)
auditable_id   :integer(4)
created_at     :datetime        not null
updated_at     :datetime        not null

Class Method Summary collapse

Class Method Details

.create_for(record) ⇒ Object



22
23
24
25
26
# File 'lib/auditable/audit_record.rb', line 22

def create_for(record)
  unless record.audited_attribute_changes.empty?
    create(:modifications => record.audited_attribute_changes, :auditable_type => record.class.to_s, :auditable_id => record.id)
  end
end

.create_for_action(record, action) ⇒ Object



27
28
29
# File 'lib/auditable/audit_record.rb', line 27

def create_for_action(record, action)
  create(:action => "#{record.class.to_s}.#{action} was called", :auditable_type => record.class.to_s, :auditable_id => record.id)
end