app/models/effective/log.rb in effective_logging-2.1.2 vs app/models/effective/log.rb in effective_logging-3.0.0
- old
+ new
@@ -10,21 +10,26 @@
# Self-Referencing relationship
belongs_to :parent, class_name: 'Effective::Log', counter_cache: true
has_many :logs, class_name: 'Effective::Log', foreign_key: :parent_id
belongs_to :user
+
+ belongs_to :changes_to, polymorphic: true # This is the log_changes to: option
belongs_to :associated, polymorphic: true
serialize :details, Hash
# Attributes
# logs_count :integer # Rails Counter Cache
+ # changes_to_type :string
+ # changes_to_id :string
+
# associated_type :string
# associated_id :integer
# associated_to_s :string
- # message :string
+ # message :text
# details :text
# status :string
# timestamps
validates :message, presence: true
@@ -35,13 +40,9 @@
scope :logged_changes, -> { where(status: EffectiveLogging.log_changes_status)}
scope :changes, -> { where(status: EffectiveLogging.log_changes_status)}
def to_s
"Log #{id}"
- end
-
- def message=(msg)
- write_attribute(:message, msg.kind_of?(String) ? msg.to_s[0...255] : msg)
end
def log(message, status = EffectiveLogging.statuses.first, options = {})
EffectiveLogger.log(message, status, (options || {}).merge(parent: self))
end