File tree Expand file tree Collapse file tree 2 files changed +51
-1
lines changed
Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Original file line number Diff line number Diff 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/
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments