0

I'm having issues trying to add a static subdomain while also running apartment gem..

Essentially I want to do something like:

constraints subdomain: 'docs' do
   get 'some/page'
end

however when I place this code in my routes file and attempt to go to docs.mysite.co I get the following error:

Apartment::TenantNotFound at /
One of the following schema(s) is invalid: "docs" "public", "shared_extensions"

my entire routes file is as follows:

class SubdomainPresent
  def self.matches?(request)
    request.subdomain.present?
  end
end

class SubdomainBlank
  def self.matches?(request)
    request.subdomain.blank?
  end
end

Rails.application.routes.draw do

  constraints subdomain: 'docs' do
     get 'some/page'
  end

  constraints(SubdomainPresent) do
    mount ImageUploader::UploadEndpoint => "/images/upload"

    root 'account_dashboard#index'

    devise_for :users
    devise_scope :user do
      get 'login', to: 'devise/sessions#new'
    end

    resources :accounts
  end

  constraints(SubdomainBlank) do
    require 'sidekiq/web'
    mount Sidekiq::Web => '/sidekiq'

    root 'visitor#index'

    resources :accounts, only: [:new, :create]
  end

end

Any assistance here would be greatly appreciated!Please let me know if I need to add further info!

EDIT # 1 Adds Application.rb

require_relative 'boot'

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module PatrolVault20161116Web
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.
    config.active_job.queue_adapter = :sidekiq
  end
end
Shawn Wilson
  • 1,311
  • 14
  • 40

1 Answers1

0

This error is caused when apartment gem cannot find a schema to run a subdomain. First, you should create a schema by creating a tenant by your subdomain name in ruby console.

Apartment::Tenant.create "docs"

After creating docs tenant in console your subdomain will be working nicely.

titan
  • 664
  • 6
  • 18