I have a Family model that
has_many Kids. I'm using
dependent: :destroy on the family so when it is destroyed the associated kids are destroyed too. All good.
Now I need to destroy the family when the last associated kid is deleted. This is to prevent stray families in the database that have no kids.
Should I do it in
students_controller#destroy method? Or is there a better way?
Join 31,152+ developers who get early access to new screencasts, articles, guides, updates, and more.