ruby-on-rails – 为什么我的mongoDB托管uri设置为mongoid.yml不能正常工作?

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 为什么我的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推送上收到以下错误

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

解决方法

尝试这个
ENV['MONGOLAB_URI'] = ds053681.mongolab.com:97321

production:
  sessions:
    default:
      hosts: 
        - <%= ENV['MONGOLAB_URI'] %>
      database: testapp_production
      username: testappuser
      password: testpassword
原文链接:https://www.f2er.com/ruby/271713.html

猜你在找的Ruby相关文章