Hi folks, For my app, I needed to modify acts_as_tree (ActiveRecord::Acts::Tree) such that deleting a node would orphan sub-nodes, rather than deleting them. This is accomplished simply by allowing a :dependent option to the acts_as_tree method so that it can be set to :nullify. For my app, I simply did this by adding a file tree.rb to my lib directory and requiring it in the model. A number of unit-test later it seems like this works fine re all the instance methods (ancestors, siblings, self_and_siblings, roots). So, I''d like to submit a patch via Trac with this small change, but since this would be my first, I thought I''d check in here before doing so to see if there is any reason why I shouldn''t, or if I should use a different approach. Thoughts? -Eric -- Department chairmen never die, they just lose their faculties. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 4/30/07, Eric Harris-Braun <eric@harris-braun.com> wrote:> > > For my app, I needed to modify acts_as_tree (ActiveRecord::Acts::Tree) > such that deleting a node would orphan sub-nodes, rather than deleting > them.If you have orphaned nodes, how do you know which one is root? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
> > For my app, I needed to modify acts_as_tree (ActiveRecord::Acts::Tree) > > such that deleting a node would orphan sub-nodes, rather than deleting > > them. > > If you have orphaned nodes, how do you know which one is root?The whole point is that I want to be able to represent multiple trees, not just one. There already is a method "roots" that works just fine when there are such orphaned nodes. The method "root" ceases really to have meaning, but that''s fine. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---