Deleting a db record in a "tree-like" model structure

Hi there,

what is the “Rails way” to delete a record in a model “tree” structure
like the following one ?

User

has_many :projects

Project

has_many :tasks

Task

has_many :sub_tasks

Sub_task

has_many :sub_sub_tasks (etc…)

-> I don’t know how to delete from my db a project record AND at the
same time delete all its dependent

  • tasks,
  • sub_tasks,
  • sub_sub_tasks, etc. with it (so that NO child record can survive in
    the db WITHOUT a parent record).

Who can help me out?!

Thank you very much for your help on this!
Tom

has_many :children, :dependent => :destroy

On Fri, Apr 11, 2008 at 4:07 PM, Tom Ha

Damn, I love it!!

Thanks a lot, Franz!