1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Clarify automatic creation/deletion of join models for has_many through

[ci-skip]
This commit is contained in:
Sean Collins 2015-11-06 12:15:31 -07:00
parent cb67c81933
commit 0aea9289f2

View file

@ -240,13 +240,15 @@ class CreateAppointments < ActiveRecord::Migration
end
```
The collection of join models can be managed via the API. For example, if you assign
The collection of join models can be managed via the [`has_many` association methods](#has-many-association-reference).
For example, if you assign:
```ruby
physician.patients = patients
```
new join models are created for newly associated objects, and if some are gone their rows are deleted.
Then new join models are automatically created for the newly associated objects.
If some that existed previously are now missing, then their join rows are automatically deleted.
WARNING: Automatic deletion of join models is direct, no destroy callbacks are triggered.