aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/association_basics.md
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-08-24 14:17:31 +0900
committerGitHub <noreply@github.com>2017-08-24 14:17:31 +0900
commitcb39b3f3ddb9e5b9adf0659a1aa826786642bf84 (patch)
tree512b3c417a8ecbb6c697f1b5f87460ddd267d664 /guides/source/association_basics.md
parent0dccf3957bec7f024f18465ad3083f65217f2b35 (diff)
parente35960f15e35b284dd909439e684eded60374414 (diff)
downloadrails-cb39b3f3ddb9e5b9adf0659a1aa826786642bf84.tar.gz
rails-cb39b3f3ddb9e5b9adf0659a1aa826786642bf84.tar.bz2
rails-cb39b3f3ddb9e5b9adf0659a1aa826786642bf84.zip
Merge pull request #30376 from willnet/belongs-to-dependent-option
[ci skip]Revert commits changing wrong place
Diffstat (limited to 'guides/source/association_basics.md')
-rw-r--r--guides/source/association_basics.md11
1 files changed, 5 insertions, 6 deletions
diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md
index 1212ae53bc..febe988b98 100644
--- a/guides/source/association_basics.md
+++ b/guides/source/association_basics.md
@@ -968,13 +968,12 @@ side of the association.
Counter cache columns are added to the containing model's list of read-only attributes through `attr_readonly`.
##### `:dependent`
-Controls what happens to associated objects when their owner is destroyed:
+If you set the `:dependent` option to:
-* `:destroy` causes the associated objects to also be destroyed.
-* `:delete_all` causes the associated objects to be deleted directly from the database (callbacks are not executed).
-* `:nullify` causes the foreign keys to be set to `NULL` (callbacks are not executed).
-* `:restrict_with_exception` causes an exception to be raised if there are associated records.
-* `:restrict_with_error` causes an error to be added to the owner if there are associated objects.
+* `:destroy`, when the object is destroyed, `destroy` will be called on its
+associated objects.
+* `:delete`, when the object is destroyed, all its associated objects will be
+deleted directly from the database without calling their `destroy` method.
WARNING: You should not specify this option on a `belongs_to` association that is connected with a `has_many` association on the other class. Doing so can lead to orphaned records in your database.