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

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