Create a Connection String
You can connect to your MongoDB deployment by providing a connection URI, also called a connection string, which instructs the driver how to connect to a MongoDB deployment and how to 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.
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 and navigate to the Clusters section. Then, click the Connect button for your new deployment.

Proceed to the Connect your application section. Select "Ruby" from the Driver selection menu and the version that best matches your installed version from the Version selection menu.
After completing these steps, you have a connection string that contains your database username and password.