Forum: Ruby on Rails polymorphic destroy of resource

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
3d9de7385f3767831cd228daef5650f9?d=identicon&s=25 Yottameter (Guest)
on 2007-04-24 08:07
(Received via mailing list)
I have a folder class which has a folder_linkable, which links a
folder id to items via their id and class. If the folder is destroyed,
I want each linking destroyed, and then each item that is linked to
destroyed. I have in the FolderLinking class:

belongs_to :folder_linkable, :polymorphic =>
true, :dependent=> :destroy

but in my unit tests, the items that are connected with
folder_linkable are not destroyed. Does dependent destroy work with

Otherwise, should I overload destroy, destroying the item, and then
deleting the item via the class delete to avoid the recursive destroy?
B8873547e864c0f41eb0ccb0f8b18ecf?d=identicon&s=25 Timo Springmann (Guest)
on 2007-04-25 21:11
(Received via mailing list)
I ran into the same problem a few days ago and havn't found a solution
this. I really wonder if this is a bug (or a missing feature) in rails
or if
I'm just missing something.

This topic is locked and can not be replied to.