Rails - Acts as Nested - Impossible move, target node cannot be inside moved tree.

183 views
Skip to first unread message

CuriousNewbie

unread,
Mar 7, 2011, 10:56:03 PM3/7/11
to rubyonra...@googlegroups.com
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

Vladimir Rybas

unread,
Mar 9, 2011, 1:30:24 PM3/9/11
to rubyonra...@googlegroups.com, CuriousNewbie
Had the same very strange bug too

> --
> 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 rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-ta...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>

Colin Law

unread,
Mar 9, 2011, 3:32:03 PM3/9/11
to rubyonra...@googlegroups.com

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

Reply all
Reply to author
Forward
0 new messages