aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_callbacks.md
diff options
context:
space:
mode:
authorJon Moss <maclover7@users.noreply.github.com>2017-04-10 09:28:42 -0500
committerGitHub <noreply@github.com>2017-04-10 09:28:42 -0500
commite8ee2187ae910cc368e3a8bf81ed7be745fb575f (patch)
treeb39c6c8df82bb609de0125fd1e24e912c93d4f14 /guides/source/active_record_callbacks.md
parent2144e70a86e6403a6298d61862e2e85615cd2a82 (diff)
parenta1d16751064afdf9f66756e3b87c6c59246907bf (diff)
downloadrails-e8ee2187ae910cc368e3a8bf81ed7be745fb575f.tar.gz
rails-e8ee2187ae910cc368e3a8bf81ed7be745fb575f.tar.bz2
rails-e8ee2187ae910cc368e3a8bf81ed7be745fb575f.zip
Merge pull request #28680 from vishalzambre/callback_doc_update
Documented issue related before_destroy with dependent: :destroy
Diffstat (limited to 'guides/source/active_record_callbacks.md')
-rw-r--r--guides/source/active_record_callbacks.md2
1 files changed, 2 insertions, 0 deletions
diff --git a/guides/source/active_record_callbacks.md b/guides/source/active_record_callbacks.md
index de0ef7c4e5..1a2c967643 100644
--- a/guides/source/active_record_callbacks.md
+++ b/guides/source/active_record_callbacks.md
@@ -117,6 +117,8 @@ Here is a list with all the available Active Record callbacks, listed in the sam
WARNING. `after_save` runs both on create and update, but always _after_ the more specific callbacks `after_create` and `after_update`, no matter the order in which the macro calls were executed.
+NOTE: `before_destroy` callback should be placed before `dependent: :destroy` associations (or use the `prepend: true` option), to ensure they execute before the records are deleted by `dependent: :destroy`.
+
### `after_initialize` and `after_find`
The `after_initialize` callback will be called whenever an Active Record object is instantiated, either by directly using `new` or when a record is loaded from the database. It can be useful to avoid the need to directly override your Active Record `initialize` method.