我到处寻找这个问题的答案,但我没有找到答案。
我正在尝试用Rails 4、devieve和公寓构建一个基于Postgres模式的多租户应用程序。对于本地Postgres服务器,我决定使用postgresap。当这个错误开始出现时,我遵循Go Rails multi-tenant guide并让这个设置(每个租户一个用户)工作。昨天当我试图安装devide的不可邀请的扩展时,这个消息在本地开始显示,我似乎找不到任何关于发生了什么的线索。
下面是我获得特定错误的方法:

michael$ rake environment db:drop
michael$ rake db:create
michael$ rake db:migrate
== 20160908204559 DeviseCreateUsers: migrating ================================
-- create_table(:users)
   -> 0.0091s
-- add_index(:users, :email, {:unique=>true})
   -> 0.0032s
-- add_index(:users, :reset_password_token, {:unique=>true})
   -> 0.0031s
-- add_index(:users, :confirmation_token, {:unique=>true})
   -> 0.0032s
-- add_index(:users, :unlock_token, {:unique=>true})
   -> 0.0029s
== 20160908204559 DeviseCreateUsers: migrated (0.0219s) =======================

    [WARNING] - The list of tenants to migrate appears to be empty. This could mean a few things:

      1. You may not have created any, in which case you can ignore this message
      2. You've run `apartment:migrate` directly without loading the Rails environment
        * `apartment:migrate` is now deprecated. Tenants will automatically be migrated with `db:migrate`

    Note that your tenants currently haven't been migrated. You'll need to run `db:migrate` to rectify this.
michael$ rake db:seed
Seeding test tenant
One of the following schema(s) is invalid: "test" "public"

在本地访问站点时,这会导致抛掷铁轨:
公寓::租户未找到
下列架构之一无效:“www”“public”
这是我的公寓.rb初始化程序:
require 'apartment/elevators/subdomain'
Apartment.configure do |config|
  config.excluded_models = %w{ User }
  config.tenant_names = lambda { User.pluck :subdomain }
  config.use_schemas = true
end
Rails.application.config.middleware.use 'Apartment::Elevators::Subdomain'

这是我的用户迁移文件:
class DeviseCreateUsers < ActiveRecord::Migration
  def change
    create_table(:users) do |t|
      ## Database authenticatable
      t.string :email,              null: false, default: ""
      t.string :encrypted_password, null: false, default: ""

      ## Recoverable
      t.string   :reset_password_token
      t.datetime :reset_password_sent_at

      ## Rememberable
      t.datetime :remember_created_at

      ## Trackable
      t.integer  :sign_in_count, default: 0, null: false
      t.datetime :current_sign_in_at
      t.datetime :last_sign_in_at
      t.string   :current_sign_in_ip
      t.string   :last_sign_in_ip

      ## Confirmable
      t.string   :confirmation_token
      t.datetime :confirmed_at
      t.datetime :confirmation_sent_at
      t.string   :unconfirmed_email # Only if using reconfirmable

      ## Lockable
      t.integer  :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
      t.string   :unlock_token # Only if unlock strategy is :email or :both
      t.datetime :locked_at

      ## Invitable
      #t.string   :invitation_token
      #t.datetime :invitation_created_at
      #t.datetime :invitation_sent_at
      #t.datetime :invitation_accepted_at
      #t.integer  :invitation_limit
      #t.integer  :invited_by_id
      #t.string   :invited_by_type

      ## User Info
      t.string :first_name
      t.string :last_name
      t.string :subdomain
      t.string :role

      t.timestamps
    end

    add_index :users, :email,                unique: true
    add_index :users, :reset_password_token, unique: true
    add_index :users, :confirmation_token,   unique: true
    add_index :users, :unlock_token,         unique: true
    #add_index :users, :invitation_token,     unique: true
  end
end

我还通过命令行进入了本地Postrgres数据库。drop正在工作,create数据库正在工作。如果需要的话我可以提供。我目前的猜测是,Rails与PostgresApp的对话方式或我的迁移方式有问题。但也许有经验的人可以指出我错过了什么。
所以我的问题是我要做什么来引起这一切?我怎样才能修好它?我怎样才能了解更多的问题呢?

最佳答案

我也有类似的错误。我的问题是我有一个现有的应用程序,我试图实现公寓宝石。
我通过在我的rails控制台中回顾性地创建每个模式来解决这个错误。

Company.all.each do |c|
  Apartment::Tenant.create(c.subdomain)
end

注意确保子域较低,例如“testsubdomain”

关于ruby-on-rails - Rails Postgres架构问题-以下架构之一无效:“test”“public”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39494139/

10-11 12:44