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 polymorphic=>true? Otherwise, should I overload destroy, destroying the item, and then deleting the item via the class delete to avoid the recursive destroy? --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Does dependent destroy work with polymorphic=>true? Otherwise, should I overload destroy, destroying the item, and then deleting the item 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. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I ran into the same problem a few days ago and havn''t found a solution to this. I really wonder if this is a bug (or a missing feature) in rails or if I''m just missing something. Regards, Timo --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Yottameter <yottameter@...> writes:> > belongs_to :folder_linkable, :polymorphic => > true, :dependent=> :destroy >Specifying :dependent=> :destroy on the has_one declaration causes the "parent" to be destroyed with the resource. You must, however, destroy the resource, not the parent, which seems a bit upside-down. -wcpr- --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---