app/models/effective/log.rb in effective_logging-3.1.0 vs app/models/effective/log.rb in effective_logging-3.1.1
- old
+ new
@@ -1,14 +1,9 @@
module Effective
class Log < ActiveRecord::Base
self.table_name = EffectiveLogging.logs_table_name.to_s
- # These 3 attr_accessors are set on the controller #show actions
- attr_accessor :datatable
- attr_accessor :next_log
- attr_accessor :prev_log
-
# Self-Referencing relationship
belongs_to :parent, class_name: 'Effective::Log', counter_cache: true, optional: true
has_many :logs, class_name: 'Effective::Log', foreign_key: :parent_id
belongs_to :user, polymorphic: true, optional: true
@@ -54,9 +49,21 @@
EffectiveLogger.log(message, status, (options || {}).merge(parent: self))
end
def details
self[:details] || {}
+ end
+
+ def next_log
+ Log.order(id: :asc).where(parent_id: parent_id).where('id > ?', id).first
+ end
+
+ def prev_log
+ Log.order(id: :desc).where(parent_id: parent_id).where('id < ?', id).first
+ end
+
+ def child_logs_datatable
+ EffectiveLogsDatatable.new(log_id: id)
end
# Dynamically add logging methods based on the defined statuses
# EffectiveLogging.info 'my message'
(EffectiveLogging.statuses || []).each do |status|