Rails 4 cache is out of sync

I have a Rails 4.2 application with a cache counter (setting c belongs_to :my_model, counter_cache: true) that sets the wrong values. I can literally call the console and call MyModel.associated_model_countand receive 20, and then call MyModel.associated_model.countand receive 19. Saving a model does not eliminate this.

The values ​​do not seem to be much removed, but some of them are explicitly disabled, and I cannot understand why.

+4
source share

Source: https://habr.com/ru/post/1621991/


All Articles