|
28 | 28 |
|
29 | 29 | *Adam Hess*
|
30 | 30 |
|
31 |
| -* Run transactional callbacks on the freshest instance to save a given |
| 31 | +* Run transactional callbacks on the freshest instance to save a given |
32 | 32 | record within a transaction.
|
33 | 33 |
|
34 |
| - When multiple Active Record instances change the same record within a |
35 |
| - transaction, Rails runs `after_commit` or `after_rollback` callbacks for |
36 |
| - only one of them. `config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction` |
37 |
| - was added to specify how Rails chooses which instance receives the |
| 34 | + When multiple Active Record instances change the same record within a |
| 35 | + transaction, Rails runs `after_commit` or `after_rollback` callbacks for |
| 36 | + only one of them. `config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction` |
| 37 | + was added to specify how Rails chooses which instance receives the |
38 | 38 | callbacks. The framework defaults were changed to use the new logic.
|
39 | 39 |
|
40 |
| - When `config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction` |
41 |
| - is `true`, transactional callbacks are run on the first instance to save, |
| 40 | + When `config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction` |
| 41 | + is `true`, transactional callbacks are run on the first instance to save, |
42 | 42 | even though its instance state may be stale.
|
43 | 43 |
|
44 |
| - When it is `false`, which is the new framework default starting with version |
45 |
| - 7.1, transactional callbacks are run on the instances with the freshest |
| 44 | + When it is `false`, which is the new framework default starting with version |
| 45 | + 7.1, transactional callbacks are run on the instances with the freshest |
46 | 46 | instance state. Those instances are chosen as follows:
|
47 | 47 |
|
48 |
| - - In general, run transactional callbacks on the last instance to save a |
| 48 | + - In general, run transactional callbacks on the last instance to save a |
49 | 49 | given record within the transaction.
|
50 | 50 | - There are two exceptions:
|
51 |
| - - If the record is created within the transaction, then updated by |
52 |
| - another instance, `after_create_commit` callbacks will be run on the |
53 |
| - second instance. This is instead of the `after_update_commit` |
| 51 | + - If the record is created within the transaction, then updated by |
| 52 | + another instance, `after_create_commit` callbacks will be run on the |
| 53 | + second instance. This is instead of the `after_update_commit` |
54 | 54 | callbacks that would naively be run based on that instance’s state.
|
55 |
| - - If the record is destroyed within the transaction, then |
56 |
| - `after_destroy_commit` callbacks will be fired on the last destroyed |
57 |
| - instance, even if a stale instance subsequently performed an update |
| 55 | + - If the record is destroyed within the transaction, then |
| 56 | + `after_destroy_commit` callbacks will be fired on the last destroyed |
| 57 | + instance, even if a stale instance subsequently performed an update |
58 | 58 | (which will have affected 0 rows).
|
59 | 59 |
|
60 | 60 | *Cameron Bothner and Mitch Vollebregt*
|
|
0 commit comments