Why am I getting the error "db_name must be a string or symbol"? Why am I getting the error "db_name must be a string or symbol"? mongodb mongodb

Why am I getting the error "db_name must be a string or symbol"?


Make sure that ENV['RACK_ENV'] is set properly, as that is what Mongoid.load! uses if it doesn't find Rails.env.


I had the same problem with rails and solved it in this way :

The Problem lies in the different expectations of Mongoid and MongodbLogger concerning the structure of the mongoid.yml.Short : just add the database in addition on the upper level :

development:  sessions:    default:      database: apollo_development                       <<<< for the rest      hosts:        - localhost:27017      options:        consistency: :strong  database: apollo_development                           <<<<main level for logger    .... more stuff for the logger

The advantage is that you can use a database for your data and another for the logger.Technical there are two independant systems using the yml : the logger and MongoId.