-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a caveat about default_scope to the README? #86
Comments
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. |
My experience with default_scope is that there are so many gotchas with
this misfeature that it's generally good advice to avoid it.
The issue with closure_tree is that the quite complicated query generation
in this gem can't incorporate arbitrary SQL from the default scope and
generate valid queries.
|
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 |
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.
The text was updated successfully, but these errors were encountered: