This issue was said to be resolved the latest version of Moped but still happens to me.
I have a rails 4.2 app with Mongoid, created a user for a MongoDB DB with readWrite and dbOwner roles, and set auth=true in the mong.conf file.
I can perform any actions on the DB with that user credentials using the Mongo shell or a simple Java application using their Mongo driver.
However, when trying to authenticate with Mongoid I always get this error:
failed with error 13: "not authorized for query on my_db.my_collection"
Here is the relevant portion of my mongoid.yml file:
production:
# Configure available database sessions. (required)
sessions:
# Defines the default session. (required)
default:
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: my_db
hosts:
- localhost:27017
username: my_username
password: my_password
I've also tried replacing the host with remote address of the server and access it remotely ( which works with the authentication option disabled ) without success. For what's it worth, I can see that the credentials by debugging the mpped/node.rb file, in the ensure_connected method I see that @credentials variable contains my username and password What am I missing here? Thanks!