Guest User

Untitled

a guest
May 16th, 2012
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. Rails 3 - Ancestry gem, root not is showing siblings.. Is that correct?
  2. parent Returns the parent of the record, nil for a root node
  3.  
  4. ruby-1.9.3-p0 :024 > c
  5. => #<Bin id: 56, heading: "Bin 1 Heading ", ..., updated_at: "2011-12-06 00:51:06", ancestry: nil>
  6. ruby-1.9.3-p0 :025 > c.parent
  7. => nil
  8. ruby-1.9.3-p0 :026 > c.has_siblings?
  9. (0.3ms) SELECT COUNT(*) FROM "bins" WHERE "bins"."ancestry" IS NULL
  10. => true
  11. ruby-1.9.3-p0 :027 > c.sibling_ids
  12. Bin Load (0.7ms) SELECT id FROM "bins" WHERE "bins"."ancestry" IS NULL
  13. => [1, 2, 3, 4, 5, 56, 57, 58, 59, 60, 111, 112, 113, 114, 115, 166, 167, 168, 169, 170, 221, 222, 223, 224, 225, 276, 277, 278, 279, 280]
  14.  
  15. bin.parent = nil # set as a root node
Advertisement
Add Comment
Please, Sign In to add comment