Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I delete orphaned children record from my model.

James Okunlade asked in General

After a parent model gets deleted it turned out the children became orphaned and I have now added a dependent destroy on the child model to ensure it gets deleted when the parent is deleted. Will updating the foreign key to do an on_delete: :cascade delete all orphaned children I have in my database on do I have to write a migration to manually get rid of the orphaned children.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,329+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.