MongoDB won't connect to MongoHQ using Mongoid

前端 未结 3 1054
你的背包
你的背包 2021-01-19 19:46

I\'ve just started a brand new rails project and the first task I\'m trying to complete is creating an object and having it save within my database. I went through the auto

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-19 20:49

    This is how my production mongoid.yml looks like

    <% if ENV['MONGOLAB_URI'] %>
      <% uri = URI.parse(ENV['MONGOLAB_URI']) %>
    production:
      <<: *defaults
      sessions:
        default:
          <<: *default_session
          database: <%= uri.path.sub('/','') %>
          username: <%= uri.user %>
          password: <%= uri.password %>
          hosts:
            - <%= uri.host %>:<%= uri.port %>
    <% end %>
    

    and this works for me

提交回复
热议问题