Class: AuditLogItem

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/audit_log_item.rb

Overview

create_table :audit_log_items do |t|

t.references :audit_log
t.references :audit_log_item_type
t.string :audit_log_item_value
t.string :audit_log_item_old_value
t.string :description

t.timestamps

end

add_index :audit_log_items, :audit_log_id, :name => ‘audit_log_items_audit_log_id_idx’ add_index :audit_log_items, :audit_log_item_type_id, :name => ‘audit_log_items_audit_log_item_type_id_idx’

Instance Method Summary collapse

Instance Method Details

#to_data_hashObject

convert to hash of data



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/audit_log_item.rb', line 24

def to_data_hash
  data = to_hash(only: [:id,
                        {audit_log_item_value: :new_value},
                        {audit_log_item_old_value: :old_value},
                        :description,
                        :created_at,
                        :updated_at])

  if audit_log_item_type
    data[:audit_log_item_type] = audit_log_item_type.to_data_hash
  end

  data
end