@@ -105,7 +105,6 @@ Add Mongoid
105105`mongoid <https://rubygems.org/gems/mongoid/>`_ gem:
106106
107107.. code-block:: ruby
108- :name: Gemfile
109108 :caption: Gemfile
110109
111110 gem 'mongoid', '~> 7.0.5'
@@ -132,6 +131,8 @@ Note that as we are not using ActiveRecord we will not have a ``database.yml``
132131file.
133132
134133
134+ .. _run-locally:
135+
135136Run MongoDB Locally
136137-------------------
137138
@@ -157,6 +158,8 @@ like this:
157158 server_selection_timeout: 1
158159
159160
161+ .. _use-atlas:
162+
160163Use MongoDB Atlas
161164-----------------
162165
@@ -247,7 +250,6 @@ Open the ``Post`` model file, ``app/models/post.rb``, and add a ``has_many``
247250association for the comments:
248251
249252.. code-block:: ruby
250- :name: app/models/post.rb
251253 :caption: app/models/post.rb
252254
253255 class Post
@@ -267,7 +269,6 @@ association for the comments:
267269 generated ``embedded_in`` association to ``belongs_to``:
268270
269271 .. code-block:: ruby
270- :name: app/models/comment.rb
271272 :caption: app/models/comment.rb
272273
273274 class Comment
@@ -283,7 +284,6 @@ Open the post show view file, ``app/views/posts/show.html.erb``, and add
283284a section rendering existing comments and prompting to leave a new comment:
284285
285286.. code-block:: html
286- :name: app/views/posts/show.html.erb
287287 :caption: app/views/posts/show.html.erb
288288
289289 <section class="section comments">
@@ -306,7 +306,6 @@ from ``text_field`` to ``text_area``, as well as the type of field for
306306should look like this:
307307
308308.. code-block:: html
309- :name: app/views/comments/_form.html.erb
310309 :caption: app/views/comments/_form.html.erb
311310
312311 <%= form_with(model: comment, local: true) do |form| %>
@@ -345,7 +344,6 @@ Create a partial for the comment view, ``app/views/comments/_comment.html.erb``
345344with the following contents:
346345
347346.. code-block:: html
348- :name: app/views/comments/_comment.html.erb
349347 :caption: app/views/comments/_comment.html.erb
350348
351349 <p>
@@ -377,7 +375,6 @@ Remove or comment out any RDBMS libraries like ``sqlite``, ``pg`` etc.
377375mentioned in ``Gemfile``, and add ``mongoid``:
378376
379377.. code-block:: ruby
380- :name: Gemfile
381378 :caption: Gemfile
382379
383380 gem 'mongoid', '~> 7.0.5'
@@ -399,7 +396,6 @@ Examine ``config/application.rb``. If it is requiring all components of Rails
399396via ``require 'rails/all'``, change it to require individual frameworks:
400397
401398.. code-block:: ruby
402- :name: config/application.rb
403399 :caption: config/application.rb
404400
405401 # Remove or comment out
@@ -472,9 +468,9 @@ Generate the default Mongoid configuration:
472468This generator will create the ``config/mongoid.yml`` configuration file,
473469which is used to configure the connection to the MongoDB deployment.
474470
475- Review the sections `Run MongoDB Locally`_ and `Use MongoDB Atlas`_
476- to decide how you would like to deploy MongoDB, and adjust Mongoid
477- configuration (``config/mongoid.yml``) to match.
471+ Review the sections :ref: `Run MongoDB Locally <run-locally>` and
472+ :ref:`Use MongoDB Atlas <use-atlas>` to decide how you would like to deploy
473+ MongoDB, and adjust Mongoid configuration (``config/mongoid.yml``) to match.
478474
479475Adjust Models
480476-------------
@@ -491,7 +487,6 @@ explicit field definitions).
491487For example, a bare-bones Post model may look like this in ActiveRecord:
492488
493489.. code-block:: ruby
494- :name: app/models/post.rb
495490 :caption: app/models/post.rb
496491
497492 class Post < ApplicationRecord
@@ -501,7 +496,6 @@ For example, a bare-bones Post model may look like this in ActiveRecord:
501496The same model may look like this in Mongoid:
502497
503498.. code-block:: ruby
504- :name: app/models/post.rb
505499 :caption: app/models/post.rb
506500
507501 class Post
@@ -516,7 +510,6 @@ The same model may look like this in Mongoid:
516510Or like this with dynamic fields:
517511
518512.. code-block:: ruby
519- :name: app/models/post.rb
520513 :caption: app/models/post.rb
521514
522515 class Post
@@ -555,5 +548,5 @@ as when creating a regular application, with the only change being the
555548Mongoid follows the same process described above for regular Rails applications.
556549
557550A complete Rails API application similar to the one described in this tutorial
558- can be found in the ` mongoid-demo GitHub repository
551+ can be found in ` the mongoid-demo GitHub repository
559552<https://github.com/mongoid/mongoid-demo/tree/master/rails-api>`_.
0 commit comments