app/models/effective/log.rb in effective_logging-1.4.1 vs app/models/effective/log.rb in effective_logging-1.5.0
- old
+ new
@@ -6,17 +6,17 @@
attr_accessor :datatable
attr_accessor :next_log
attr_accessor :prev_log
# Self-Referencing relationship
- belongs_to :parent, :class_name => 'Effective::Log', :counter_cache => true
- has_many :logs, :dependent => :destroy, :class_name => 'Effective::Log', :foreign_key => :parent_id
+ belongs_to :parent, class_name: 'Effective::Log', counter_cache: true
+ has_many :logs, class_name: 'Effective::Log', foreign_key: :parent_id
# The user this log item is referring to
# An associated object, if we wanna add anything extra
belongs_to :user
- belongs_to :associated, :polymorphic => true
+ belongs_to :associated, polymorphic: true
serialize :details, Hash
# structure do
# logs_count :integer # Rails Counter Cache
@@ -24,20 +24,20 @@
# details :text
# status :string, :validates => [:presence, :inclusion => {:in => EffectiveLogging.statuses }]
# timestamps
# end
- validates_presence_of :message, :status
- validates_inclusion_of :status, in: EffectiveLogging.statuses
+ validates :message, presence: true
+ validates :status, presence: true, inclusion: { in: (EffectiveLogging.statuses + [EffectiveLogging.log_changes_status]) }
- default_scope -> { order("#{EffectiveLogging.logs_table_name.to_s}.updated_at DESC") }
+ default_scope -> { order(updated_at: :desc) }
def log(message, status = EffectiveLogging.statuses.first, options = {})
EffectiveLogger.log(message, status, (options || {}).merge({:parent => self}))
end
def details
- ((self[:details] ||= {}) rescue {})
+ self[:details] || {}
end
# def next_log
# @next_log ||= Log.unscoped.order(:id).where(:parent_id => self.parent_id).where('id > ?', self.id).first
# end