aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2013-08-12 06:57:36 -0700
committerSteve Klabnik <steve@steveklabnik.com>2013-08-12 06:57:36 -0700
commit4d1e5847cd2f8dfc566c12d3b9e5e7f811f53282 (patch)
tree2de54215a4359b8a966450d6831b946ba0b01e79 /guides/source
parentbd14099e2ffbcbc33dfa36e274edca98a4921daa (diff)
parentac02c190a50370500c72527e30a1da5e0d2da82c (diff)
downloadrails-4d1e5847cd2f8dfc566c12d3b9e5e7f811f53282.tar.gz
rails-4d1e5847cd2f8dfc566c12d3b9e5e7f811f53282.tar.bz2
rails-4d1e5847cd2f8dfc566c12d3b9e5e7f811f53282.zip
Merge pull request #11852 from prijutme4ty/guide_addition
Added comment to a guide about necessity of `:dependent` option for asso... [ci skip]
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/association_basics.md6
1 files changed, 6 insertions, 0 deletions
diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md
index 9b80a65a44..e133e71d42 100644
--- a/guides/source/association_basics.md
+++ b/guides/source/association_basics.md
@@ -1137,6 +1137,12 @@ Controls what happens to the associated object when its owner is destroyed:
* `: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
+It's necessary not to set or leave `:nullify` option for those associations
+that have `NOT NULL` database constraints. If you don't set `dependent` to
+destroy such associations you won't be able to change the associated object
+because initial associated object foreign key will be set to unallowed `NULL`
+value.
+
##### `:foreign_key`
By convention, Rails assumes that the column used to hold the foreign key on the other model is the name of this model with the suffix `_id` added. The `:foreign_key` option lets you set the name of the foreign key directly: