diff --git a/source/quick-start-sinatra.txt b/source/quick-start-sinatra.txt index 176b4efd..11814e03 100644 --- a/source/quick-start-sinatra.txt +++ b/source/quick-start-sinatra.txt @@ -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/ diff --git a/source/quick-start-sinatra/configure-mongodb.txt b/source/quick-start-sinatra/configure-mongodb.txt new file mode 100644 index 00000000..716104d1 --- /dev/null +++ b/source/quick-start-sinatra/configure-mongodb.txt @@ -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:pass123@mongo0.example.com/sample_restaurants + + .. 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 ```` placeholder + with your connection string that references the target database: + + .. code-block:: yaml + :emphasize-lines: 4 + + development: + clients: + default: + uri: + +After completing these steps, your Sinatra web application is ready to +connect to MongoDB. + +.. include:: /includes/quick-start/troubleshoot.rst