Sha256: 7c5651b8df43a2373798f4e218982f39ccff5bbec505f2a4450b33e6ed9559de
Contents?: true
Size: 737 Bytes
Versions: 4
Compression:
Stored size: 737 Bytes
Contents
# -*- encoding : utf-8 -*- module Mongoid module Userstamps module Created extend ActiveSupport::Concern included do if !self.included_modules.include?(Mongoid::Userstamps::Model) include Mongoid::Userstamps::Model end belongs_to userstamps_config.created_name, { class_name: userstamps_model.user_model, inverse_of: nil, optional: true } set_callback :create, :before, :set_created_by end def set_created_by user = self.class.current_user return if !user || self.public_send(userstamps_config.created_name) self.public_send("#{userstamps_config.created_name}=", user) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems