#1353 new
kematzy

DM 1.0.0 & dm-is-tree & destroy

Reported by kematzy | July 6th, 2010 @ 05:01 AM

Please see gist [ http://gist.github.com/465158 ] for the problem code.

The basic problem is that when you enable dm-is-tree on a model, then the before :destroy callback stops working.

With the gist code in mind, I find these errors:

m.destroy  # => does nothing!

m.destroy! # => deletes the model record, but does not execute the callbacks (as expected)

This is even weirder:

-- with [ is :tree, :order => [:parent_id, :position] ] enabled:

Album.all.each{ |a| a.destroy }   # => deletes the records, but NOT the first record

Album.all.destroy   # =>  does nothing!

Album.all.destroy!   # =>  destroys all records, but does not trigger callback

Album.destroy!   # =>  destroys all records, but does not trigger callback

-- without [ is :tree, :order => [:parent_id, :position] ]:

m.destroy  # => works as expected, deletes and triggers callback

m.destroy! # => deletes the model record, but does not execute the callbacks (as expected)

Album.all.each{ |a| a.destroy }   # => deletes all the records, including the first record with callbacks

Album.all.each{ |a| a.destroy! }   # => deletes all the records, without callbacks

Album.all.destroy   # =>  deletes all the records, with callbacks

Album.all.destroy!   # =>  deletes all the records, without callbacks

Album.destroy     # =>  deletes all the records, with callbacks

Album.destroy!    # =>  deletes all the records, but does NOT trigger the callback

As you can see, the behaviour of #destroy / #destroy! are not exactly consistent, nor in my mind logical.

I apologise for not having the time right now to try to fix this right now.

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Pages