Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Rails 3 - Ancestry gem, root not is showing siblings.. Is that correct?
- parent Returns the parent of the record, nil for a root node
- ruby-1.9.3-p0 :024 > c
- => #<Bin id: 56, heading: "Bin 1 Heading ", ..., updated_at: "2011-12-06 00:51:06", ancestry: nil>
- ruby-1.9.3-p0 :025 > c.parent
- => nil
- ruby-1.9.3-p0 :026 > c.has_siblings?
- (0.3ms) SELECT COUNT(*) FROM "bins" WHERE "bins"."ancestry" IS NULL
- => true
- ruby-1.9.3-p0 :027 > c.sibling_ids
- Bin Load (0.7ms) SELECT id FROM "bins" WHERE "bins"."ancestry" IS NULL
- => [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]
- bin.parent = nil # set as a root node
Advertisement
Add Comment
Please, Sign In to add comment