Почему мой mongoDB-хостинг настроек uri для mongoid.yml работает некорректно?
В настоящее время я использую следующие параметры (, который не работает) в моем файле mongoid.yml, и я правильно добавил переменную окружения MONGOLAB_URI
в мою среду heroku:
production:
sessions:
default:
another:
uri: <%= ENV['MONGOLAB_URI'] %>
Я также пробовал следующее: не работает:
production:
uri: <%= ENV['MONGOLAB_URI'] %>
Это также не работает:
production:
sessions:
default:
uri: <%= ENV['MONGOLAB_URI'] %>
Я получаю следующую ошибку при нажатии героя:
Running: rake assets:precompile
There is a configuration error with the current mongoid.yml.
Problem:
No database provided for session configuration: :default.
Summary:
Each session configuration must provide a database so Mongoid knows where the default database to persist to. What was provided was: {"another"=>{"uri"=>nil}}.
Resolution:
If configuring via a mongoid.yml, ensure that within your :default section a :database value for the session default database is defined.
Example:
\_\_development:
\_\_\_\_sessions:
\_\_\_\_\_\_default:
\_\_\_\_\_\_\_\_database: my_app_db
\_\_\_\_\_\_\_\_hosts:
\_\_\_\_\_\_\_\_\_\_- localhost:27017
There is a configuration error with the current mongoid.yml.
Problem:
No database provided for session configuration: :default.
Summary:
Each session configuration must provide a database so Mongoid knows where the default database to persist to. What was provided was: {"another"=>{"uri"=>nil}}.
Resolution:
If configuring via a mongoid.yml, ensure that within your :default section a :database value for the session default database is defined.
Example:
\_\_development:
\_\_\_\_sessions:
\_\_\_\_\_\_default:
\_\_\_\_\_\_\_\_database: my_app_db
\_\_\_\_\_\_\_\_hosts:
\_\_\_\_\_\_\_\_\_\_- localhost:27017
Asset precompilation completed (15.47s)
Что я здесь делаю неправильно? Я следил за инструкциями mongoid.org:
http://mongoid.org/en/mongoid/docs/installation.html
Я использую mongoid 3.0.0.rc
Ответы
Ответ 1
Попробуйте это
ENV['MONGOLAB_URI'] = ds053681.mongolab.com:97321
production:
sessions:
default:
hosts:
- <%= ENV['MONGOLAB_URI'] %>
database: testapp_production
username: testappuser
password: testpassword
Ответ 2
Пример абха не работал у меня. Это то, что наконец-то сработало:
production:
sessions:
default:
uri: <%= ENV['MONGOHQ_URI'] %>
options:
skip_version_check: true
safe: true
Ответ 3
Из https://devcenter.heroku.com/articles/mongolab#mongoid-5
production:
clients:
default:
uri: <%= ENV['MONGOLAB_URI'] %>