Почему мой 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'] %>

Я получаю следующую ошибку на Heroku push:

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's 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's 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

3 ответов


попробуй такое

ENV['MONGOLAB_URI'] = ds053681.mongolab.com:97321

production:
  sessions:
    default:
      hosts: 
        - <%= ENV['MONGOLAB_URI'] %>
      database: testapp_production
      username: testappuser
      password: testpassword

пример абхаса не сработал для меня. Вот что наконец сработало:

production:   
  sessions:
    default:
      uri: <%= ENV['MONGOHQ_URI'] %>
      options:
        skip_version_check: true
        safe: true

от https://devcenter.heroku.com/articles/mongolab#mongoid-5

production:
  clients:
    default:
      uri: <%= ENV['MONGOLAB_URI'] %>