Sha256: 697dc08b47b0c7da69758af91a1304d38353118792f6263d507c0b22ebc12e62
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 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: Cms.user_class_name belongs_to :updated_by, class_name: Cms.user_class_name before_save :set_userstamps scope :created_by, lambda { |user| { conditions: { created_by: user } } } scope :updated_by, lambda { |user| { conditions: { updated_by: user } } } end end module ClassMethods end module InstanceMethods def set_userstamps current_user = Cms::User.current ? Cms::User.current : nil if new_record? self.created_by = current_user end self.updated_by = current_user end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
browsercms-artirix-4.0.0.rc1.art4 | lib/cms/behaviors/userstamping.rb |