aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/association_basics.md
diff options
context:
space:
mode:
authorJon Moss <maclover7@users.noreply.github.com>2016-03-11 16:30:06 -0500
committerJon Moss <maclover7@users.noreply.github.com>2016-03-11 16:30:06 -0500
commitf500e27df5ea9205c63daa624c4e9027cb1f1fde (patch)
treedf4dd3637950b045b054031fc0b220e7f5f8d012 /guides/source/association_basics.md
parent92f869a0c852689078298fcb7b3019ccd2f2f7f9 (diff)
parent5147ab121d628f29451c654a8c312d5a3f491ffb (diff)
downloadrails-f500e27df5ea9205c63daa624c4e9027cb1f1fde.tar.gz
rails-f500e27df5ea9205c63daa624c4e9027cb1f1fde.tar.bz2
rails-f500e27df5ea9205c63daa624c4e9027cb1f1fde.zip
Merge pull request #24155 from chrisarcand/clarify-has-many-dependent-option
Clarify has_many :dependent option docs [ci skip]
Diffstat (limited to 'guides/source/association_basics.md')
-rw-r--r--guides/source/association_basics.md16
1 files changed, 7 insertions, 9 deletions
diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md
index 0ffdf037f7..67fd758fe1 100644
--- a/guides/source/association_basics.md
+++ b/guides/source/association_basics.md
@@ -932,15 +932,13 @@ side of the association.
Counter cache columns are added to the containing model's list of read-only attributes through `attr_readonly`.
##### `:dependent`
-If you set the `:dependent` option to:
-
-* `:destroy`, when the object is destroyed, `destroy` will be called on its
-associated objects.
-* `:delete_all`, when the object is destroyed, all its associated objects will be
-deleted directly from the database without calling their `destroy` method.
-* `:nullify`, causes the foreign key to be set to `NULL`. Callbacks are not executed.
-* `:restrict_with_exception`, causes an exception to be raised if there is an associated record
-* `:restrict_with_error`, causes an error to be added to the owner if there is an associated object
+Controls what happens to associated objects when their owner is destroyed:
+
+* `: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.
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.