微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.jb51.cc/ruby/271713.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐