0

我在尝试添加静态子域的同时还运行公寓 gem 时遇到问题。

基本上我想做类似的事情:

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
4

1 回答 1

0

apartment gem找不到运行subdomain. 首先,您应该通过在控制台中创建tenant子域名来创建架构。ruby

Apartment::Tenant.create "docs"

在控制台中创建docs租户后,您的子域将运行良好。

于 2016-11-22T09:05:35.777 回答