Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Problems with 'adopt' orphan strategy #114

bodrovis opened this Issue · 1 comment

2 participants


Hello. I've met some problems when implementing "adopt" orphan strategy.

First, when just putting "gem 'ancestry'" to my gemfile i got an error saying that there is no such strategy, though the version of the gem was 1.3.0. I explored the source code and this strategy was actually there, so i had to put "gem 'ancestry', git: ''" and it solved the problem.

But the main problem is related to ordering. I have an app with comments and replies. Comments are ordered by creation date (the newest are first). I use this construction: "arrange(:order => 'created_at DESC')" and do not have any "default_scope" in my model. Replies are showed just under the corresponding comment.

Everything is working fine until i begin to delete replies. For instance, i have:

-- Root comment

--- Reply to it (1)

---- Reply to reply (2)

So when i delete the root comment, the reply (1) becomes root (as far as i understood), reply (2) becomes its only child. But for some strange reason the ordering breaks and this group of comment and reply goes to the bottom of the list (right under the last comment). Other comments and replies has the corrent ordering, but after deleting some other root comment the corresponding branch goes to the end of the list too. This does not happen, if i delete reply (1) or reply (2) - only when i delete the root comment. I cannot manage to fix it.

Any clues about this issue?


Adopt will be available in the 2.0 release

you are ordering by created_at? reply 1 might have a different created_at then the root comment.

@StefanH StefanH closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.