stefankroes/ancestry

children_count not always in sync with the actual count of children

seenanair opened this issue · 3 comments

We have been using the Ancestry gem for a while, and as part of the implementation, we are utilizing the counter_cache feature, which allows us to use the children_count column. However, we are encountering an issue where the children_count is not always in sync with the actual count of children.

I was wondering if anyone else has faced a similar issue, and if so, it would be great to hear about any solutions or possible reasons this might be happening. Could it be that the Ancestry callbacks are being interfered with, possibly due to the order in which they are executed alongside model object callbacks?

Is there a way to ensure that Ancestry updates occur after all model object callbacks have been executed?

Thank you!

Hello @seenanair
I've had trouble reproducing this, but it is definitely has been seen before
You may want to also look at #584

@kbrock Thanks for your quick reply. Yes, It is hard to reproduce.
Seeing the update, I hope it is better to use rebuild_counter_cache as a fix?
Also, I can see it is not yet released. Is there any plans for a release soon?

@seenanair I will release soon.