Callback has_many

Hi everyone,

I am implementing fragment caching in my application

I’ve got the following architecture :

A :has_many Cs :through Bs

I’ve got a sweeper that observes B, in which I’ve got 2 methods :
after_create(B) and after_delete(B), which expire a fragment of my

In my main controller, I adding/removing Cs to As like this :

A << C, and this actually calls back after_create(B), as expected


A.Cs.delete© which doesn’t perform any call to after_delete(B), even
though, the B element is actually deleted!

Is this a normal behavior? If so, why is the call back only called when
creating and not deleting? And is there a “smart” way to actually call
by sweeper on delete?

Thanks for your help!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs