From 5147ab121d628f29451c654a8c312d5a3f491ffb Mon Sep 17 00:00:00 2001 From: Chris Arcand Date: Fri, 11 Mar 2016 11:22:34 -0500 Subject: 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. --- guides/source/association_basics.md | 16 +++++++--------- 1 file 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. -- cgit v1.2.3