Create a Connection String
You can connect to your MongoDB deployment by providing a connection URI, also called a connection string, which tells Mongoid how to connect to a MongoDB deployment and behave while connected.
The connection string includes the hostname or IP address and port of your deployment, the authentication mechanism, user credentials when applicable, and connection options.
To learn about connecting to an instance or deployment not hosted on Atlas, see Connection Strings in the Server manual.
Find your MongoDB Atlas connection string
To retrieve your connection string for the deployment that you created in the previous step, log in to your Atlas account. Then, navigate to the Database section and click the Connect button for your new deployment.

Proceed to the Connect your application section. Select Ruby from the Driver selection menu and the most recent Ruby driver version from the Version selection menu.
Deselect the View full code sample option to view only the connection string.
After completing these steps, you have a connection string that contains your database username and password.
Note
If you run into issues, ask for help in the MongoDB Community Forums or submit feedback by using the Feedback button in the upper right corner of the page.