Class: ActivityLog
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- ActivityLog
- Defined in:
- app/models/activity_log.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#user ⇒ Object
Custom user lookup to support both SQL and Mongo users.
Class Method Details
.log(user_id, action, target = nil, details = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/activity_log.rb', line 8 def self.log(user_id, action, target = nil, details = nil) log_entry = { user_id: user_id.to_s, action: action, created_at: Time.now } if target log_entry[:target_type] = target.class.name log_entry[:target_id] = target.id.to_s rescue nil end if details log_entry[:details] = details.is_a?(Hash) ? details.to_json : details.to_s end create(log_entry) end |