Files
dunlop-core/app/models/dunlop/last_attribute_change.rb
T
2018-01-20 13:02:44 -03:00

11 lines
385 B
Ruby

# This model keeps track of the timestamp (changed_at) when
# attributes of other models are changed the last time
class Dunlop::LastAttributeChange < ApplicationRecord
belongs_to :target, polymorphic: true, optional: true
validates :attribute_name, presence: true
before_validation on: :create do
self.changed_at = Time.now unless attribute_present?(:changed_at)
end
end