title: Change parent of existing node that has children
body: <p>I am using rails 5 with ancestry gem. I have a Group model, and its records are already arranged in a tree. Now I pick up a group randomly which has children and try to change it's parent_id. The group object gets saved but the tree structure does not change as expected i.e. only one node gets moved not its children. Here is my code:</p>
  
  <pre><code>  def change_hierarchy(parent)
      if valid_move?(parent)
        self.parent_id= self.read_attribute(:parent_id) + '/' + parent.read_attribute(:parent_id)
        self.save
        true
      else
        false
      end
    end
  </code></pre>