Mongoid; ERROR Mongo :: Error :: OperationFailure: not authorized for request

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 go into the mongo console and create / find documents just with the credentials that I use in mongoid.yml.

mongoid.yml:

production:
  clients:
    default:
      database: my_db
      hosts:
        - myhost:port
      username: db_user
      password: my_password
+4
source share
1 answer

Format Off try it

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

Pay attention to the section optionsand username-user

+4
source

Source: https://habr.com/ru/post/1627496/


All Articles