Skip to content

Add a caveat about default_scope to the README? #86

Closed

Description

@bithive

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.

Activity

  1. mceachen commented on May 12, 2014

    @mceachen
    Collaborator

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

  2. geordee commented on Sep 28, 2014

    @geordee

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

  3. jmuheim commented on Dec 8, 2015

    @jmuheim

    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.

  4. mceachen commented on Dec 8, 2015

    @mceachen
    Collaborator
  5. kaoru commented on Nov 26, 2018

    @kaoru

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions