2016-11-22 28 views
0

我有問題,嘗試添加靜態子域,同時運行公寓寶石..添加靜態子域公寓租戶軌之外4

基本上我想要做的事,如:

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

然而,我在我的路線文件放在這個代碼,並試圖去docs.mysite.co我得到以下錯誤:

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

我的整個路線文件如下:

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 

在這裏的任何幫助將不勝感激!請讓我知道,如果我需要添加更多的信息!

編輯#1又添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 
+0

你能顯示你的application.rb嗎? – titan

+0

抱歉@titan虐待現在添加。 –

回答

0

此錯誤時apartment gem無法找到一個模式來運行subdomain引起的。首先,您應該通過在ruby控制檯中通過您的子域名創建tenant來創建架構。

Apartment::Tenant.create "docs" 

在控制檯中創建docs tenant後,您的子域將會很好地工作。

+0

負..沒有工作,我不需要將它們添加到application.rb,因爲它們在初始化器中。 –

+0

@ShawnWilson你找到任何解決方案嗎? – titan

+0

還沒有。 –