12

私は現在、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 プッシュで次のエラーが発生します。

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を使用しています

4

3 に答える 3

10

abhas の例は私にはうまくいきませんでした。これが最終的に機能したものです:

production:   
  sessions:
    default:
      uri: <%= ENV['MONGOHQ_URI'] %>
      options:
        skip_version_check: true
        safe: true
于 2012-07-16T13:53:00.840 に答える
8

これを試して

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

production:
  sessions:
    default:
      hosts: 
        - <%= ENV['MONGOLAB_URI'] %>
      database: testapp_production
      username: testappuser
      password: testpassword
于 2012-06-27T04:31:46.090 に答える
2

https://devcenter.heroku.com/articles/mongolab#mongoid-5から

production:
  clients:
    default:
      uri: <%= ENV['MONGOLAB_URI'] %>
于 2016-08-10T14:59:43.780 に答える