我添加了生产数据库,如下所示:
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进行部署?
答案 0 :(得分:13)
他们更新了Mongoid 5中mongoid.yml文件的格式。而不是sessions
它必须是clients
。还有一些其他更改,我知道user
和password
现在嵌套在选项之下,与之前不同。有关详细信息,请参阅Mongoid docs。
production:
clients:
default:
...