Sha256: c801ce6627845ce3969ef5b44342d7413fead2516eeff1bdde44a07876e180fd

Contents?: true

Size: 516 Bytes

Versions: 8

Compression:

Stored size: 516 Bytes

Contents

module ActsAsTenant
  module ControllerExtensions
    module Subdomain
      extend ActiveSupport::Concern

      included do
        cattr_accessor :tenant_class, :tenant_column, :subdomain_lookup
        before_action :find_tenant_by_subdomain
      end

      private

      def find_tenant_by_subdomain
        if (subdomain = request.subdomains.send(subdomain_lookup))
          ActsAsTenant.current_tenant = tenant_class.where(tenant_column => subdomain.downcase).first
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
acts_as_tenant-1.0.1 lib/acts_as_tenant/controller_extensions/subdomain.rb
acts_as_tenant-1.0.0 lib/acts_as_tenant/controller_extensions/subdomain.rb
acts_as_tenant-0.6.1 lib/acts_as_tenant/controller_extensions/subdomain.rb
acts_as_tenant-0.6.0 lib/acts_as_tenant/controller_extensions/subdomain.rb
acts_as_tenant-0.5.3 lib/acts_as_tenant/controller_extensions/subdomain.rb
acts_as_tenant-0.5.2 lib/acts_as_tenant/controller_extensions/subdomain.rb
acts_as_tenant-0.5.1 lib/acts_as_tenant/controller_extensions/subdomain.rb
acts_as_tenant-0.5.0 lib/acts_as_tenant/controller_extensions/subdomain.rb