Skip to content

Passing touch along to ancestors instead of descendants (for cache expiry of nested content)? #253

Open
@nruth

Description

@nruth

:touch delegates to the belongs_to annotation for the parent, so touching cascades to all children (the performance of this for deep trees isn't currently optimal).

So, when a parent is updated it passes on the timestamp change to its children (descendants?).

I'd like the reverse behaviour, with an updated child passing its timestamp changes up to all of its ancestors. Something like this:

after_save :touch_ancestors_for_cache_expiry

def touch_ancestors_for_cache_expiry
  ancestors.to_a.each(&:touch)
end

Would it make sense to support both of these in the has_closure_tree call?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions