为什么我的mongoDB托管uong设置为mongoid.yml无法正常工作?

Goa*_*lie 12 ruby-on-rails heroku mongodb mongoid

我正在使用mongoid.yml中的以下设置(不起作用),并且我已正确地将MONGOLAB_URI环境变量添加到我的heroku环境中:

production:
  sessions:
    default:
      another:
        uri: <%= ENV['MONGOLAB_URI'] %>
Run Code Online (Sandbox Code Playgroud)

我也尝试了以下不起作用:

production:
  uri: <%= ENV['MONGOLAB_URI'] %>
Run Code Online (Sandbox Code Playgroud)

这也行不通:

production:
  sessions:
    default:
      uri: <%= ENV['MONGOLAB_URI'] %>
Run Code Online (Sandbox Code Playgroud)

我在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)
Run Code Online (Sandbox Code Playgroud)

我在这做错了什么?我遵循了mongoid.org的说明:

http://mongoid.org/en/mongoid/docs/installation.html
Run Code Online (Sandbox Code Playgroud)

我正在使用mongoid 3.0.0.rc

cde*_*sch 10

abhas的例子对我不起作用.这是最终奏效的:

production:   
  sessions:
    default:
      uri: <%= ENV['MONGOHQ_URI'] %>
      options:
        skip_version_check: true
        safe: true
Run Code Online (Sandbox Code Playgroud)


abh*_*has 7

试试这个

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

production:
  sessions:
    default:
      hosts: 
        - <%= ENV['MONGOLAB_URI'] %>
      database: testapp_production
      username: testappuser
      password: testpassword
Run Code Online (Sandbox Code Playgroud)