aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorChris Arcand <chris@chrisarcand.com>2016-03-11 11:22:34 -0500
committerChris Arcand <chris@chrisarcand.com>2016-03-11 16:07:09 -0500
commit5147ab121d628f29451c654a8c312d5a3f491ffb (patch)
tree0923d5c06af04349469ff6da9a1259ffb3130fdf /guides
parentf8d9c0510742b4f2d440f5223803453aaf0fbab0 (diff)
downloadrails-5147ab121d628f29451c654a8c312d5a3f491ffb.tar.gz
rails-5147ab121d628f29451c654a8c312d5a3f491ffb.tar.bz2
rails-5147ab121d628f29451c654a8c312d5a3f491ffb.zip
Clarify has_many :dependent option docs [ci skip]
Clarifies the documentation here to mean all options are for when the relation is destroyed; also now reflects the documentation on this same option found in the has_one section.
Diffstat (limited to 'guides')
-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.