acts_as_tree "soft destroy", ie. "move up" children

By default, when you destroy a parent node all of the children nodes
are destroyed as well.

Is there a way I can modify this so that when you destroy a parent
node all the children nodes are simply "moved up" within the tree?

Thanks!

come to think of it, I should probably just create my own function
called destroy_and_move_up or something =P

I tried that already.

def before_destroy
self.children.each {|child|
  child.parent_id = nil
  child.save
}
end

(Yeah, I know, it doesn't "move them up", it just sets them to new
root nodes)

However, rails won't let me do that. It says I can't modify a frozen
hash. I'm not sure what that means, but I assume it means I can't
modify things that are about to be destroyed.

> put it in the before_destroy callback of the model

I tried using the before_destroy for a similar purpose - I wanted to
stop deletion if the node has children. But I ran into trouble, the
children were destroyed anyway. From what I have read elsewhere in
this group, I believe the before_destroy is only called after
dependent_destroy is actioned. That may be what is happening here.

Seems to me to write a seperate method may be the way to go.

Tonypm