You’re calling delete_all on an association, even if it’s weird, for
deleting an association means only breaking the links between the
not effectively destroying the records. Semantically, this makes sense,
I grant you that it’s a bit counter intuitive.
but what’s resoning behind this default behaviour? Is it just a legacy
anyone knows why the default behaviour here is to nullify keys?
Actually, the Rails documentation explains this rather clearly, so the
behavior you’re seeing is exactly as it was intended.
Deletes all the records from the collection. For has_many associations,
the deletion is done according to the strategy specified by the
:dependent option. Returns an array with the deleted records.
If no :dependent option is given, then it will follow the default
strategy. The default strategy is :nullify. This sets the foreign keys
to NULL. For, has_many :through, the default strategy is delete_all.