From 647cff3a134772bc6374b89e95d13497e23b5309 Mon Sep 17 00:00:00 2001 From: Kuldeep Aggarwal Date: Fri, 29 Nov 2013 18:49:56 +0530 Subject: updating options documentation for associations removed unnecessary test case and improved test case for belongs_to having invalid options --- guides/source/association_basics.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index c0482f6106..9867d2dc3f 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -864,8 +864,12 @@ end 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: -If you set the `:dependent` option to `:destroy`, then deleting this object will call the `destroy` method on the associated object to delete that object. If you set the `:dependent` option to `:delete`, then deleting this object will delete the associated object _without_ calling its `destroy` method. If you set the `:dependent` option to `:restrict`, then attempting to delete this object will result in a `ActiveRecord::DeleteRestrictionError` if there are any 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. -- cgit v1.2.3