I want to do the following:
after_commit :on => :destroy do
Advert.clean_total_active_cache
end
But in a observer-like fashion like this:
class AdvertObserver < ActiveRecord::Observer
def after_commit advert
Advert.clean_total_active_cache
end
end
It’s the “:on => :destroy”, that’s causing me trouble, how do I specify that?
You can check if the record is not persisted and frozen: