I have category model that has a tree structure. In my database I have about 1500 records.
When I try rebuild ancestry from parent id with command “Category.build_ancestry_from_parent_ids!” I get nil as a result.
Here are results.
1.9.2p290 :006 > Category.build_ancestry_from_parent_ids!
Category Load (1.8ms) SELECT “categories”.* FROM “categories” WHERE “categories”.”parent_id” IS NULL AND (“categories”.”id” >= 0) ORDER BY “categories”.”id” ASC LIMIT 1000
=> nil
I’m following directions from https://github.com/stefankroes/ancestry , but seems like I am missing something.
Is any one had same issue before?
I found the solution. I had to put parameters to make this work properly.
It’s possible to put
parent_id =1, then transition will skip all categories that belong to the root level.