Mark For Destruction
Do you have some complicated logic or criteria for deleting associated records? ActiveRecord's #mark_for_destruction
may come in handy.
Let's say we have users who author articles. We want to delete some of the user's articles based on some criteria -- those articles that have odd id
s.
We've marked our articles for destruction and confirmed as much with the #marked_for_destruction?
method. Now, to go through with the destruction, we just have to save the parent record -- the user.
Note: the parent record must have autosave: true
declared on the association.
Last updated