Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7738087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:10:19+00:00 2026-06-01T08:10:19+00:00

I have category model that has a tree structure. In my database I have

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:10:21+00:00Added an answer on June 1, 2026 at 8:10 am

    I found the solution. I had to put parameters to make this work properly.

    Category.build_ancestry_from_parent_ids!(parent_id =0 , ancestry =0)
    

    It’s possible to put parent_id =1, then transition will skip all categories that belong to the root level.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a database of urls(links). I have a Category model that
I have a Model Category which has name:string categoryId:integer parent_id:integer the categoryId doesnt matter
In my code I have a Category model which has many subcategories, and the
I have a Category and Subcategory model. Category has many subcategories and Subcategory belongs
I have a Store Model that can have multiple products. Each product has a
I have a Post model that belongs to a single category and author. Users
I have the following complex model: Category - has -> List which has ->
I have a Blog model that has defined var $hasMany=array(Comment); How can i apply
I have a auction model and a category model. Auction belongs_to category and category
I have a Category and a Post model, with each Post belonging to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.