Tim Uckun wrote in post #976165:
>>
>> No. Destroy has to instantiate each object prior to actually removing it from
> the database in order to run any before/after destroy call backs.
>>
>> You can speed things up if you don't need this by tweaking the :dependent 
option
> to has_many so that it will simply use SQL's DELETE on the child
> objects... but
> that of course won't run any callbacks (your own, or Rail's counter
> cache, etc.)
>
> Actually it doesn't HAVE to instantiate them if it can query the
> relationships in a meaningful matter. Of course we know that it CAN
> query those relationships and calculate what has to be deleted.

Unfortunately, that's not always all that a before_destroy callback 
does.  Since that's the case, there's no general method for executing 
the callbacks without instantiating all those objects.

Of course, if you know you don't need the callbacks, it's perfectly fine 
to use delete_all instead.

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to