I have a contact management system where I have "items" and "relationships". The relationship is the glue between items. It has two polymorphic belongs_to called parent and child that link to an item. An item can be a person, company, address, etc. The create side of things is beginning to firm up. I want to come up with an approach on how to do deletes. What I want to have happen is if you delete an item. Then all the relationships to that item need to be deleted as well. But, on top of that, if that leaves other items in the database that have no relation pointing to them, those need to be deleted. One thought is to start a transaction, do the delete of the first item. Then search and delete relations that are pointing to something that no longer exists. Then search and delete items that have nothing pointing to them. Then commit the transaction. Does anyone else have any suggestions? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---