You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
446 B

10 years ago
module Stampable
extend ActiveSupport::Concern
10 years ago
included do
belongs_to :creator, :class_name => 'User'
belongs_to :updator, :class_name => 'User'
10 years ago
before_create :set_creator_attribute
before_save :set_updator_attribute
end
10 years ago
def set_creator_attribute
10 years ago
self.creator = User.current unless creator_id?
10 years ago
end
def set_updator_attribute
10 years ago
self.updator = User.current unless updator_id? && updator_id_changed?
10 years ago
end
end