From 411829fdb5f24f97ce17e05f5fd018d47075b216 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Fri, 3 Jul 2015 14:54:50 +0300 Subject: Audit log for user authentication --- app/models/audit_event.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 app/models/audit_event.rb (limited to 'app/models/audit_event.rb') diff --git a/app/models/audit_event.rb b/app/models/audit_event.rb new file mode 100644 index 00000000000..967ffd46db0 --- /dev/null +++ b/app/models/audit_event.rb @@ -0,0 +1,19 @@ +class AuditEvent < ActiveRecord::Base + serialize :details, Hash + + belongs_to :user, foreign_key: :author_id + + validates :author_id, presence: true + validates :entity_id, presence: true + validates :entity_type, presence: true + + after_initialize :initialize_details + + def initialize_details + self.details = {} if details.nil? + end + + def author_name + self.user.name + end +end -- cgit v1.2.1