4

I am creating an application using ruby/grape and mongoid. But when I try to create or find a document in any collection using mongoid, for example with Admin.create I get the following error:

ERROR Mongo::Error::OperationFailure: not authorized for query on databse.collection

I can log in to mongo console and create/find documents just fine with the credentials I use in mongoid.yml.

mongoid.yml:

production:
  clients:
    default:
      database: my_db
      hosts:
        - myhost:port
      username: db_user
      password: my_password
Haider
  • 254
  • 1
  • 10

1 Answers1

4

You're format is off. Try this

production:
  clients:
    default:
      database: my_db
      hosts:
        - myhost:port
      options:
        user: db_user
        password: my_password

Notice the options section and that username is user

Jake Hoffner
  • 1,037
  • 9
  • 17