aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/association_basics.md
diff options
context:
space:
mode:
authorKuldeep Aggarwal <kd.engineer@yahoo.co.in>2013-11-29 18:49:56 +0530
committerKuldeep Aggarwal <kd.engineer@yahoo.co.in>2013-11-29 18:49:56 +0530
commit647cff3a134772bc6374b89e95d13497e23b5309 (patch)
treeb82e5ea545bf0792f4276a33cadf38bb3010429d /guides/source/association_basics.md
parent948c0ff1647eb3dd1b45add0d1748d393cd2fd50 (diff)
downloadrails-647cff3a134772bc6374b89e95d13497e23b5309.tar.gz
rails-647cff3a134772bc6374b89e95d13497e23b5309.tar.bz2
rails-647cff3a134772bc6374b89e95d13497e23b5309.zip
updating options documentation for associations
removed unnecessary test case and improved test case for belongs_to having invalid options
Diffstat (limited to 'guides/source/association_basics.md')
-rw-r--r--guides/source/association_basics.md6
1 files changed, 5 insertions, 1 deletions
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.