ClosureTree/closure_tree

Add a caveat about default_scope to the README?

bithive opened this issue ยท 5 comments

I just spent way too long trying to figure out why closure_tree wasn't working for me; it turns out that I had declared

default_scope { order('id asc') }

in my model and it was causing trees to misbehave when they contained children whose IDs where less than that of their parent. Perhaps my blunder can be documented to help others avoid similar headaches.

Bummer! I'll add a warning to the README.

Is it just the "order" in the default_scope? How about if I define a default_scope with a "where"?

I've come here from the README. But I don't really get the point: what exactly is the problem? I'm in the process of choosing a gem for creating trees, and I'd like to choose closure_tree, but first I'd like to know what the caveat is with this issue.

Thanks for explaining a bit deeper.

kaoru commented

I suspect this is the problem I'm having too. I've got a default scope thanks to the paranoia gem, and even though none of the records I'm trying to add to a hierarchy it seems like the whole thing isn't working properly with the scope set ๐Ÿ˜ข

I wonder if this could be made to work by having an option to has_closure_tree that would make it always use #unscoped.