Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/quick-start-sinatra.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ that connects to a MongoDB deployment.
/quick-start-sinatra/download-and-install/
/quick-start-sinatra/create-a-deployment/
/quick-start-sinatra/create-a-connection-string/
/quick-start-sinatra/configure-mongodb/

.. /quick-start-sinatra/configure-mongodb/
.. /quick-start-sinatra/view-data/
.. /quick-start-sinatra/write-data/
.. /quick-start-sinatra/next-steps/
50 changes: 50 additions & 0 deletions source/quick-start-sinatra/configure-mongodb.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.. _mongoid-quick-start-sinatra-connect-to-mongodb:

=================================
Configure Your MongoDB Connection
=================================

.. facet::
:name: genre
:values: tutorial

.. meta::
:keywords: test connection, runnable, code example

.. procedure::
:style: connected

.. step:: Specify target database in connection string

When connecting to an Atlas cluster, you must specify the database that
you want to interact with as the default database in your connection string.
You must add the database name to your connection string **after the hostname**.

The following example specifies the ``sample_restaurants`` target database
in a sample connection string:

.. code-block:: none

mongodb+srv://user0:[email protected]/sample_restaurants
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mongodb+srv://user0:pass123@mongo0.example.com/sample_restaurants
mongodb+srv://<username>:<password>@mongo0.example.com/sample_restaurants

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave the connection string as is an specify that its a sample


.. step:: Specify connection

At the root level of your project, create a ``config`` directory.
Then, create a file in this directory called ``mongoid.yml``.

Paste the following configuration into the ``mongoid.yml`` file,
making sure to replace the ``<connection string>`` placeholder
with your connection string that references the target database:

.. code-block:: yaml
:emphasize-lines: 4

development:
clients:
default:
uri: <connection string>

After completing these steps, your Sinatra web application is ready to
connect to MongoDB.

.. include:: /includes/quick-start/troubleshoot.rst
Loading