{"issue":{"state":"closed","pull_request":{"diff_url":"https://github.com/benedikt/mongoid-tree/pull/20.diff","html_url":"https://github.com/benedikt/mongoid-tree/pull/20","patch_url":"https://github.com/benedikt/mongoid-tree/pull/20.patch"},"user":{"avatar_url":"https://secure.gravatar.com/avatar/49de4cd2f26705785cbef2b15a9df7aa?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"49de4cd2f26705785cbef2b15a9df7aa","url":"https://api.github.com/users/nickhoffman","login":"nickhoffman","id":21668},"milestone":null,"labels":[],"assignee":null,"updated_at":"2011-11-01T13:11:33Z","closed_at":"2011-11-01T06:34:46Z","comments":2,"url":"https://api.github.com/repos/benedikt/mongoid-tree/issues/20","body":"Hey there, Benedikt. I just found a bug with ancestors and Tree::Ordering.\r\n\r\nIf you have a tree like this:\r\n\r\n```\r\n- root:\r\n  - level_1_a\r\n  - level_1_b:\r\n    - level_2_a:\r\n      - leaf\r\n```\r\n\r\n`leaf.ancestors` returns `[root, level_2_a, level_1_b]`, which is obviously incorrect.\r\n\r\nThis occurs because of the default scope of ascending position. `level_2_a`'s position is 0, `level_1_b`'s position 1, so MongoDB sorts `level_2_a` before `level_1_b`.\r\n\r\nThe solution is to make Tree::Ordering query the base class *unscoped*.\r\n\r\nCheers,\r\nNick","html_url":"https://github.com/benedikt/mongoid-tree/issues/20","number":20,"title":"Ancestors are returned in their correct order when using Tree::Ordering","id":2104325,"created_at":"2011-11-01T02:23:20Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/49de4cd2f26705785cbef2b15a9df7aa?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"49de4cd2f26705785cbef2b15a9df7aa","url":"https://api.github.com/users/nickhoffman","login":"nickhoffman","id":21668},"updated_at":"2011-11-01T13:11:33Z","url":"https://api.github.com/repos/benedikt/mongoid-tree/issues/comments/2590023","body":"You're very welcome, mate. Thanks for merging it in so quickly.","id":2590023,"created_at":"2011-11-01T13:11:33Z"}}