11 lines
385 B
Ruby
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
|