Skip to content

Commit 3f8e885

Browse files
authored
Merge pull request #49 from rustagir/DOCSP-42735-configure-cxn-sinatra
DOCSP-42735: configure cxn
2 parents 41d810b + 7255928 commit 3f8e885

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

source/quick-start-sinatra.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ that connects to a MongoDB deployment.
5757
/quick-start-sinatra/download-and-install/
5858
/quick-start-sinatra/create-a-deployment/
5959
/quick-start-sinatra/create-a-connection-string/
60+
/quick-start-sinatra/configure-mongodb/
6061

61-
.. /quick-start-sinatra/configure-mongodb/
6262
.. /quick-start-sinatra/view-data/
6363
.. /quick-start-sinatra/write-data/
6464
.. /quick-start-sinatra/next-steps/
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.. _mongoid-quick-start-sinatra-connect-to-mongodb:
2+
3+
=================================
4+
Configure Your MongoDB Connection
5+
=================================
6+
7+
.. facet::
8+
:name: genre
9+
:values: tutorial
10+
11+
.. meta::
12+
:keywords: test connection, runnable, code example
13+
14+
.. procedure::
15+
:style: connected
16+
17+
.. step:: Specify target database in connection string
18+
19+
When connecting to an Atlas cluster, you must specify the database that
20+
you want to interact with as the default database in your connection string.
21+
You must add the database name to your connection string **after the hostname**.
22+
23+
The following example specifies the ``sample_restaurants`` target database
24+
in a sample connection string:
25+
26+
.. code-block:: none
27+
28+
mongodb+srv://user0:[email protected]/sample_restaurants
29+
30+
.. step:: Specify connection
31+
32+
At the root level of your project, create a ``config`` directory.
33+
Then, create a file in this directory called ``mongoid.yml``.
34+
35+
Paste the following configuration into the ``mongoid.yml`` file,
36+
making sure to replace the ``<connection string>`` placeholder
37+
with your connection string that references the target database:
38+
39+
.. code-block:: yaml
40+
:emphasize-lines: 4
41+
42+
development:
43+
clients:
44+
default:
45+
uri: <connection string>
46+
47+
After completing these steps, your Sinatra web application is ready to
48+
connect to MongoDB.
49+
50+
.. include:: /includes/quick-start/troubleshoot.rst

0 commit comments

Comments
 (0)