diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-11-13 19:17:14 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-13 19:17:14 -0500 |
commit | debf35620f3ec06de4eb970600bbd35716984e9d (patch) | |
tree | 7e9b8b7cef8fe60e8a78790c2acda41dcd51e371 /guides/source | |
parent | 0b75743e345f98d3f53f5a29fcd0e91d2a370a24 (diff) | |
parent | 39806b6d98c1dbcbaac6748274e2cc3fbfba3495 (diff) | |
download | rails-debf35620f3ec06de4eb970600bbd35716984e9d.tar.gz rails-debf35620f3ec06de4eb970600bbd35716984e9d.tar.bz2 rails-debf35620f3ec06de4eb970600bbd35716984e9d.zip |
Merge pull request #34441 from mcary/document-dependent-effects
Describe how has_many's :dependent option affects #delete
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/association_basics.md | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index f75517c5ab..822dee08f0 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -1662,6 +1662,8 @@ Controls what happens to the associated objects when their owner is destroyed: * `:restrict_with_exception` causes an `ActiveRecord::DeleteRestrictionError` exception to be raised if there are any associated records * `:restrict_with_error` causes an error to be added to the owner if there are any associated objects +The `:destroy` and `:delete_all` options also affect the samantics of the `collection.delete` and `collection=` methods by causing them to destroy associated objects when they are removed from the collection. + ##### `: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: |