2

I know that destroy cascade will work if proper relationships are setup in the models, but I want to know whether there is a way to destroy cascade on-the-fly, without needing to have everything setup? Maybe something like model.destroy :cascade?

Or am I limited to raw SQL in this case?

Suan
  • 34,563
  • 13
  • 47
  • 61

1 Answers1

1

I haven't heard of way of doing it on the fly, but rather than using raw SQL try this:

AssociatedModel.destroy_all(:model_id => @model.id)
@model.destroy