2

ローカル マシンでの開発用と heroku でのステージング用に 2 つの環境を作成しました。

ここに私の「mongoid.yml」があります:

development:
  sessions:
    default:
      database: mydb_development
      hosts:
        - localhost:27017
staging:
  sessions:
    default:
      database: mydb_staging
      uri: <%= ENV['MONGOLAB_URI'] %>

Mongoid はローカル マシンでは正常に動作しますが、heroku のデプロイ後に次のエラーが発生します。

/app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.14/lib/mongoid/config/validators/session.rb:81:in `validate_session_uri':  (Mongoid::Errors::MixedSessionConfiguration)
2012-12-25T10:12:44+00:00 app[web.1]: Problem:
2012-12-25T10:12:44+00:00 app[web.1]:   Both uri and standard configuration options defined for session: 'default'.
2012-12-25T10:12:44+00:00 app[web.1]: Summary:
2012-12-25T10:12:44+00:00 app[web.1]:   Instead of simply giving uri or standard options a preference order, Mongoid assumes that you have made a mistake in your configuration and requires that you provide one or the other, but not both. The options that were provided were: {"database"=>"xxxxx_staging", "uri"=>"mongodb://xxxxx:xxxxx@xxxxx.mongolab.com:37587/xxxxxx"}.
2012-12-25T10:12:44+00:00 app[web.1]: Resolution:
2012-12-25T10:12:44+00:00 app[web.1]:   Provide either only a uri as configuration or only standard options.

「構成としてURIのみを提供するか、標準オプションのみを提供する」というフレーズは何を意味しますか? 開発とステージングのためにモンゴイドを適切に構成するには?

4

1 に答える 1

7

次の行を削除します。

database: mydb_staging

データベース名が URI に含まれているためです。

于 2012-12-25T13:48:58.307 に答える