I have a lot of has_many: through relationships in my application. I am extensivley showing information related to this, for example, the number of connected objects. Whenever the user updates the relation, the connection table changes, and I can catch it with my sweepers.
The problem is that the connection table entries are deleted , not destroyed . If the relationship is gone, I have no way to find this, and I will show the misleading information from the cache. Everything like: touch => true, or: counter_cache => true works partially. It increases if relationships are updated or created. But if the user deletes the relationship, nothing happens .: counter_cache becomes broken: touch does not work.
The garbage solution should call .touch on the controller when the main model is saved. This kind of work, but it seems really unprofessional. This should be in the logic of the model, not in the controllers.
I feel like I'm missing something big, but I bow my head over it. Can anyone talk about this issue?
mdrozdziel
source share