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-25 02:54
(Received via mailing list)
Does dependent destroy work with polymorphic=>true? Otherwise,
should I overload destroy, destroying the item, and then deleting the
via the class delete to avoid the recursive destroy?

This doesn't work:

class FolderLinking < ActiveRecord::Base

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

when an instance of FolderLinking is destroyed, I want the item that
it links to destroyed. I'm currently seeing the folder_linkable
sticking around.
17aaba150513c54e2bdf612eacc9107e?d=identicon&s=25 Paul Rogers (Guest)
on 2007-04-27 22:26
(Received via mailing list)
Yottameter <yottameter@...> writes:

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

Specifying :dependent=> :destroy on the has_one declaration causes the
to be destroyed with the resource. You must, however, destroy the
resource, not
the parent, which seems a bit upside-down.

This topic is locked and can not be replied to.