module KirguduBase module Concerns::Models::ManagedBy extend ActiveSupport::Concern included do before_query :query_add_managed_by belongs_to :manager, class_name: ::KirguduBase::Security::User, foreign_key: :managed_by scope :by_managed_by, lambda { |value| where(managed_by: value) if value } end def manager_name self.manager.full_name if self.manager end module ClassMethods def query_add_managed_by(query, filters) query.by_managed_by(filters[:managed_by]) end end end end