@@ -37,11 +37,11 @@ Mongoid supports the following callbacks for :doc:`documents </tutorials/documen
37
37
- ``after_destroy``
38
38
39
39
Callbacks are available on any document, whether it is embedded within
40
- another document or not. Note that to be efficient, Mongoid only fires
41
- the callback of the document that the persistence action was executed on.
42
- This is that Mongoid aims to support large hierarchies and to handle
43
- optimized atomic updates callbacks can't be firing all over the document
44
- hierarchy.
40
+ another document or not. Note that to be efficient, Mongoid only invokes
41
+ the callback on the document that the persistence action was executed on.
42
+ This enables Mongoid to support large hierarchies and to handle optimized
43
+ atomic updates efficiently (without invoking callbacks throughout the document
44
+ hierarchy) .
45
45
46
46
Note that using callbacks for domain logic is a bad design practice, and can
47
47
lead to unexpected errors that are hard to debug when callbacks in
@@ -82,20 +82,20 @@ syntax as well:
82
82
end
83
83
end
84
84
85
+
85
86
Association Callbacks
86
87
=====================
87
88
88
- Mongoid has a set of callbacks that are specific to collection based
89
- associations - these are:
89
+ Mongoid has a set of callbacks that are specific to associations - these are:
90
90
91
91
- ``after_add``
92
92
- ``after_remove``
93
93
- ``before_add``
94
94
- ``before_remove``
95
95
96
- Each time a document is added or removed from any of the following associations,
97
- the respective callbacks are invoked: ``embeds_many``,
98
- ``has_many``, and ``has_and_belongs_to_many``.
96
+ Each time a document is added or removed from any of the following
97
+ associations, the respective callbacks are invoked: ``embeds_many``,
98
+ ``has_many`` and ``has_and_belongs_to_many``.
99
99
100
100
Association callbacks are specified as options on the respective association.
101
101
The document added/removed will be passed as the parameter to the specified
0 commit comments