Sha256: 5673963b8bd9a07a473bfee12e8a665ffbd08bd1c787dcacd8e94c3e705a6584

Contents?: true

Size: 693 Bytes

Versions: 6

Compression:

Stored size: 693 Bytes

Contents

module ModelsAuditor
  class AuditRecord < ActiveRecord::Base
    ACTION_CREATE  = 0
    ACTION_UPDATE  = 1
    ACTION_DESTROY = 2

    establish_connection [ModelsAuditor.config.connection_namespace, Rails.env].map(&:presence).compact.join('_').to_sym
    self.table_name = ModelsAuditor.config.audit_records_table_name

    belongs_to :request, class_name: ModelsAuditor::AuditRequest.name, foreign_key: :request_id
    belongs_to :auditable, polymorphic: true, foreign_key: :object_id, foreign_type: :object_type

    enum action: {action_create: ACTION_CREATE, action_update: ACTION_UPDATE, action_destroy: ACTION_DESTROY}

    validates :object_type, :object_id, presence: true
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
models_auditor-1.0.2 app/models/models_auditor/audit_record.rb
models_auditor-1.0.1 app/models/models_auditor/audit_record.rb
models_auditor-1.0.0 app/models/models_auditor/audit_record.rb
models_auditor-0.2.0 app/models/models_auditor/audit_record.rb
models_auditor-0.1.1 app/models/models_auditor/audit_record.rb
models_auditor-0.1.0 app/models/models_auditor/audit_record.rb