Ticket #15 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Problem/misunderstanding with roots

Reported by: anonymous Assigned to: jcm
Priority: major Milestone: 0.1 with tests
Component: plugin Version: 0.1
Keywords: Cc:

Description

In a test case, Category.roots returns three roots (they all have a parent_id)

but, if I perform the root? method on two of those categories, it returns false because lft is required to be 1.

Is this not inconsistent?

I'm also unable to create multiple roots. How is this supposed to be done? If I set the scope to "root_id" then it looks like a proper root (parent_id = nil, and lft = 1) is created, but if I try to move_to anywhere I get an error. If this is all be design, a little documentation on roots and their creation could really help.

Change History

09/11/06 15:27:56 changed by jcm

  • status changed from new to assigned.
  • owner changed from somebody to jcm.

Hi,

Scope and parent_id are thwo different things. Scope is intended to store multiple trees in the same table, each one caracterized by a different scope value. Root or Roots are the top items, without any parent. A traditional tree has only a root, though having multiple roots is often useful (avoids having a virtual and ignored real unique root).

It's true that root? is not yet consistent with roots. I kept old nested_set code for compatibility. I'll unify all this as soon as tests are up and running.

10/10/06 13:36:18 changed by jcm

  • version set to 0.1.
  • component changed from component1 to plugin.
  • milestone set to 0.1 with tests.

11/12/06 22:29:19 changed by jcm

root? is kept only for compatibility with existent code; we'll remove it after 0.1 version (the one with tests and a working scope) is out. Maybe we should correct root? to return correct info.

12/12/06 03:19:10 changed by Krishna

  • status changed from assigned to closed.
  • resolution set to fixed.

I have added documentation and examples of virtual roots and scope usage to the README. Unfortunately, I think that multiple roots may still be a point of confusion for people.

#root? is now consistent with #roots et al.