Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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/
52 changes: 52 additions & 0 deletions source/quick-start-sinatra/configure-mongodb.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.. _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**.

We want to access the ``sample_restaurants`` database for this tutorial.
For example, if the connection string for your Atlas cluster is
``"mongodb+srv://user0:[email protected]/"``, you can
specify the target database as shown in the following code:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can be modified to just introduce the code example to avoid using "we" and to make it more closely mirror our other repos.

Suggested change
We want to access the ``sample_restaurants`` database for this tutorial.
For example, if the connection string for your Atlas cluster is
``"mongodb+srv://user0:[email protected]/"``, you can
specify the target database as shown in the following code:
The following example specifies the ``sample_restaurants`` database in a 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

In your project, create the ``config`` directory, then create a
file in this directory called ``mongoid.yml``.

Paste the following configuration into the file, making sure to
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
Paste the following configuration into the file, making sure to
Paste the following configuration into the ``mongoid.yml`` file, making sure to

replace the ``<connection string>`` placeholder with your connection
string that contains 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