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.

19 lines
482 B

11 years ago
module Stampable
extend ActiveSupport::Concern
included do
belongs_to :creator, :class_name => 'User'
belongs_to :updator, :class_name => 'User'
before_create :set_creator_attribute
before_save :set_updator_attribute
end
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