CuriousNewbie
2011-Mar-08 03:56 UTC
Rails - Acts as Nested - Impossible move, target node cannot be inside moved tree.
Hello, I''m using the Awesome Nested Set plugin: https://github.com/collectiveidea/awesome_nested_set And in my model I do the following: acts_as_nested_set after_save :ensure_max_nestedset_level private def ensure_max_nestedset_level if self.level > 2 self.move_to_child_of(parent.parent) end end I do this to keep the levels from getting to deep. Any idea why I''m getting this "Impossible move, target node cannot be inside moved tree." error? What''s strange is it happens on production but I can''t replicate it on Dev. Thanks -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Vladimir Rybas
2011-Mar-09 18:30 UTC
Re: Rails - Acts as Nested - Impossible move, target node cannot be inside moved tree.
Had the same very strange bug too On Tue, Mar 8, 2011 at 6:56 AM, CuriousNewbie <bhellman1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, I''m using the Awesome Nested Set plugin: > https://github.com/collectiveidea/awesome_nested_set > > And in my model I do the following: > acts_as_nested_set > after_save :ensure_max_nestedset_level > private > def ensure_max_nestedset_level > if self.level > 2 > self.move_to_child_of(parent.parent) > end > end > I do this to keep the levels from getting to deep. Any idea why I''m getting > this "Impossible move, target node cannot be inside moved tree." error? > What''s strange is it happens on production but I can''t replicate it on Dev. > > Thanks > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Mar-09 20:32 UTC
Re: Rails - Acts as Nested - Impossible move, target node cannot be inside moved tree.
On 8 March 2011 03:56, CuriousNewbie <bhellman1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, I''m using the Awesome Nested Set plugin: > https://github.com/collectiveidea/awesome_nested_set > > And in my model I do the following: > acts_as_nested_set > after_save :ensure_max_nestedset_level > private > def ensure_max_nestedset_level > if self.level > 2 > self.move_to_child_of(parent.parent) > end > end > I do this to keep the levels from getting to deep. Any idea why I''m getting > this "Impossible move, target node cannot be inside moved tree." error? > What''s strange is it happens on production but I can''t replicate it on Dev.I suggest that you put some logging in immediately before the move and log details of self, parent and parent.parent and see what is shown when it crashes. My guess is that the tree is messed up in some way and you have ended up with something like self being its own grandparent. Another suggestion is to look at the code of Awsome Nested Set and see what is the condition that generates this error. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.