Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my mongoDB hosting uri settings for mongoid.yml not working correctly?

I'm currently using the following settings (which does not work) in my mongoid.yml and i've correctly added the MONGOLAB_URI environmental variable to my heroku environment:

production:
  sessions:
    default:
      another:
        uri: <%= ENV['MONGOLAB_URI'] %>

I also tried the following which does not work:

production:
  uri: <%= ENV['MONGOLAB_URI'] %>

This also does not work:

production:
  sessions:
    default:
      uri: <%= ENV['MONGOLAB_URI'] %>

I'm getting the following error on the heroku push:

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)

What am I doing wrong here? I've followed the mongoid.org instructions:

http://mongoid.org/en/mongoid/docs/installation.html

I am using mongoid 3.0.0.rc

like image 395
Goalie Avatar asked Jun 26 '12 21:06

Goalie


2 Answers

Try this

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

production:
  sessions:
    default:
      hosts: 
        - <%= ENV['MONGOLAB_URI'] %>
      database: testapp_production
      username: testappuser
      password: testpassword
like image 152
abhas Avatar answered Sep 20 '22 06:09

abhas


abhas's example didn't work for me. This is what finally worked:

production:   
  sessions:
    default:
      uri: <%= ENV['MONGOHQ_URI'] %>
      options:
        skip_version_check: true
        safe: true
like image 22
cdeutsch Avatar answered Sep 18 '22 06:09

cdeutsch