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 8500699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:00:54+00:00 2026-06-11T01:00:54+00:00

I have a simple hierarchy that I’m trying to build. class Category < ActiveRecord::Base

  • 0

I have a simple hierarchy that I’m trying to build.

class Category < ActiveRecord::Base
  attr_accessible :name

  belongs_to :parent, class_name: "Category"
  has_many :children, class_name: "Category", foreign_key: :parent_id
end

I can add categories to a tree and it works fine. However, things do not work as expected when deleting. For example:

root = Category.new(:name => "Root")
child = Category.new(:name => "Child")
child.parent = root
# things are fine to this point. root.children contains child,
# and child.parent is root

root.children.delete child
# at this point root.children is empty, but child.parent is still root

Any ideas what might be happening here? Thanks!

  • 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-11T01:00:54+00:00Added an answer on June 11, 2026 at 1:00 am

    Answer: it’s product.reload

    This explanation is the first one I’ve found after hours searching:
    https://stackoverflow.com/a/7449957/456280

    (Also this is directly related to my question here: Delete in Many to Many Relationship Not Symmetric? )

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

Sidebar

Related Questions

I have a simple Class Hierarchy that I am trying to get to work
I have a simple class hierarchy where I have a virtual method that is
I have a simple - trivial - UIView parent/child hierarchy. One parent (UIView). One
I have a class manipulating only shared_ptr to an inheritance hierarchy (quite simple, there
I have a simple CMS system, that has a simple tree hierarchy: We have
I have simple class with width and height member fields which define number of
I have simple php validation form that is halfway working. If you leave the
I have simple win service, that executes few tasks periodically. How should I pass
Facts I have a pretty simple table: ID, name, PARENT_ID I would like to
I have a simple object hierarchy, and I want to query each of the

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.