Skip to content

Commit cb5eeab

Browse files
psaghm
authored andcommitted
Fix transactions docs
1 parent c430dee commit cb5eeab

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

docs/index.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ framework for MongoDB in Ruby.
1818
/tutorials/mongoid-persistence
1919
/tutorials/mongoid-queries
2020
/tutorials/mongoid-sessions
21+
/tutorials/mongoid-transactions
2122
/tutorials/mongoid-relations
2223
/tutorials/mongoid-nested-attributes
2324
/tutorials/mongoid-callbacks

docs/tutorials/mongoid-transactions.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ when starting a transaction:
5555
``commit_transaction`` and ``abort_transaction``, again on the session instance:
5656

5757
.. code-block:: ruby
58+
5859
Person.with_session do |session|
5960
session.commit_transaction
6061
end
@@ -70,6 +71,7 @@ The transaction commit `can be retried <https://docs.mongodb.com/manual/core/tra
7071
if it fails. Here is the Ruby code to do so:
7172

7273
.. code-block:: ruby
74+
7375
begin
7476
session.commit_transaction
7577
rescue Mongo::Error => e
@@ -84,6 +86,7 @@ Note that in order to perform operations within the transaction, operations must
8486
that the session was initiated on. By default, all operations will be done on the default client:
8587

8688
.. code-block:: ruby
89+
8790
class Person
8891
include Mongoid::Document
8992
end
@@ -103,6 +106,7 @@ that the session was initiated on. By default, all operations will be done on th
103106
To explicitly use a different client, use the ``with`` method:
104107

105108
.. code-block:: ruby
109+
106110
Post.with(client: :other) do
107111
Person.with(client: :other) do
108112
Person.with_session do |s|

0 commit comments

Comments
 (0)