Felix Bünemann

Results 317 comments of Felix Bünemann

OK, it looks like the `after_update :update_parents_counter_cache` is not required on rails 5, I'll have to check with older rails versions as well to develop a proper fix.

This looks to me to be a rails counter cache bug: * If I disable the `after_update` hook, the counts are wrong if I use `update_attributes(parent_id: new_parent.id)` * If I...

I have created a failing test case for activerecord and will open an upstream bug. There is already a working fix in rails/rails#23357, but it is not yet merged.

Reported upstream issue rails/rails#28203.

I'm not sure if there's anything we can do about this problem in `acts_as_tree`, removing the existing hook would break `update`, but fix column assignment… If a fix is merged...

@etdsoft Maybe you could switch your controller code to use `model.update(new_attributes)` to work around the issue for now?

Does it work correctly, if you override the `update_parents_counter_cache` method with an empty method? ```ruby def update_parents_counter_cache end ``` Or is the decrement not done? In that case you could...

This is strange, because `children` should be a `has_many` association, which cannot return `nil`. Maybe you have a method on your model that overrides the default `children` association?

This sounds similar to the ActiveRecord bug described in issue rails/rails#28579. Could you try if the bug is fixed by using rails master?

What are you trying to achieve and what would be common use cases?