【问题标题】:When attempting to create the new client, Mongoid could not find a client configuration for the name: 'default'尝试创建新客户端时,Mongoid 找不到名称的客户端配置:'default'
【发布时间】:2015-11-01 18:26:34
【问题描述】:

我添加了生产数据库如下:

production:
  sessions:
    default:
      uri: <%= ENV['MONGOHQ_URL'] %>
      options:
        consistency: :strong
        max_retries: 1
        retry_interval: 0

依赖于以下docs

我通过以下命令创建了MONGOHQ_URL

heroku config:add MONGOHQ_URL=mongodb://user:pass@server.mongohq.com:port/db_name

但是当我通过heroku run rails c 打开控制台时。我得到了以下信息:

There is a configuration error with the current mongoid.yml.

message:
  No clients configuration provided.
summary:
  Mongoid's configuration requires that you provide details about each client that can be connected to, and requires in the clients config at least 1 default client to exist.
resolution:
  Double check your mongoid.yml to make sure that you have a top-level clients key with at least 1 default client configuration for it. You can regenerate a new mongoid.yml for assistance via `rails g mongoid:config`.

 Example:
   development:
     clients:
       default:
         database: mongoid_dev
         hosts:
           - localhost:27017

Loading production environment (Rails 4.2.4) 

如何在 mongoid.yml 文件中添加生产配置以使用 heroku 进行部署?

【问题讨论】:

  • 可能存在重复的here

标签: ruby-on-rails heroku deployment mongoid mongohq


【解决方案1】:

他们在 Mongoid 5 中更新了 mongoid.yml 文件的格式。而不是 sessions 它需要是 clients。还有一些其他的变化,我知道 userpassword 现在嵌套在 options 下,不像以前。详情请见Mongoid docs

production:
  clients:
    default:
      ...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-19
    • 1970-01-01
    • 1970-01-01
    • 2020-10-19
    • 2018-09-30
    • 2017-10-26
    • 2014-10-06
    • 1970-01-01
    相关资源
    最近更新 更多