Sha256: ed051f02eaa086ad633fcdffc0ff3ef73d3f77a4e7e4bab3148fba0a026c6ad8
Contents?: true
Size: 661 Bytes
Versions: 8
Compression:
Stored size: 661 Bytes
Contents
module ActsAsTenant module ControllerExtensions module SubdomainOrDomain extend ActiveSupport::Concern included do cattr_accessor :tenant_class, :tenant_primary_column, :tenant_second_column, :subdomain_lookup before_action :find_tenant_by_subdomain_or_domain end private def find_tenant_by_subdomain_or_domain subdomain = request.subdomains.send(subdomain_lookup) query = subdomain.present? ? {tenant_primary_column => subdomain.downcase} : {tenant_second_column => request.domain.downcase} ActsAsTenant.current_tenant = tenant_class.where(query).first end end end end
Version data entries
8 entries across 8 versions & 1 rubygems