Sha256: 28bff5a5587485b2fbd242e5688ee3a636c8bbf52a5fabcc05d11792cd532c30
Contents?: true
Size: 1 KB
Versions: 35
Compression:
Stored size: 1 KB
Contents
module Cms module Behaviors module Userstamping def self.included(model_class) model_class.extend(MacroMethods) end module MacroMethods def userstamped? !!@is_userstamped end def is_userstamped(options={}) @is_userstamped = true extend ClassMethods include InstanceMethods belongs_to :created_by, :class_name => "User" belongs_to :updated_by, :class_name => "User" before_save :set_userstamps named_scope :created_by, lambda{|user| {:conditions => {:created_by => user}}} named_scope :updated_by, lambda{|user| {:conditions => {:updated_by => user}}} end end module ClassMethods end module InstanceMethods def set_userstamps if new_record? self.created_by = User.current end self.updated_by = User.current end end end end end
Version data entries
35 entries across 35 versions & 11 rubygems