Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Callbacks on changes to tree? #34

Closed
kerinin opened this Issue · 3 comments

3 participants

@kerinin

I don't see any way to handle callbacks for changes to the ancestry tree, for example if I need to do something when a a node's parent is changed, or a new child is added.

I could hack around it using dirty attributes, but it doesn't seem like that works either.

@stefankroes
Owner

What about:

def after_create
  parent.child_created! unless parent.nil?
end

def after_save
  children.each &:parent_saved!
end
@noahhendrix

Would you recommend this as the most effect way of "touching" the root of the child to set the updated_at column?

@stefankroes
Owner

yeah, why not?

def after_create
  root.touch
end

should work great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.