# app/controllers/concerns/multitenancy.rb
module Multitenancy
  extend ActiveSupport::Concern

  included do
    before_action :multitenancy_detector
    # or
    prepend_before_action :multitenancy_detector
  end

  def multitenancy_detector
    # your logic here
  end
end