I currently have this kind of setup:
:procedures, has_many => :steps
Steps are tied to the procedures that they were created under. Currently my method destroy for Procedures is just this:
def destroy
@procedure.destroy
end
Is it necessary to go find all the steps associated with this procedure and invoke their destroy methods, or will Rails handle this for me automatically?
You can get the dependent sub-items included in the destroy by using the ‘:dependent => :destroy’ option.
So in your case it’d be:
Which will destroy steps when the procedure is destroyed.
You could also use:
Which from the rails site
So the delete_all won’t trigger destroy callbacks and destroy will.