Alex Rivera | Logout

How do I 'validate' on destroy in rails

Asked 2008-09-23T19:04:33.540
92

On destruction of a restful resource, I want to guarantee a few things before I allow a destroy operation to continue? Basically, I want the ability to stop the destroy operation if I note that doing so would place the database in a invalid state? There are no validation callbacks on a destroy operation, so how does one "validate" whether a destroy operation should be accepted?

Edit
Report

1 Answer

6

The ActiveRecord associations has_many and has_one allows for a dependent option that will make sure related table rows are deleted on delete, but this is usually to keep your database clean rather than preventing it from being invalid.

answered 2008-09-23T22:16:49.957

Your Answer