ActiveRecord Global Callbacks for all Models

前端 未结 5 867
清酒与你
清酒与你 2020-12-31 20:06

I have around 40 models in my RoR application. I want to setup a after_save callback for all models. One way is to add it to all models. Since this callback has the same cod

5条回答
  •  心在旅途
    2020-12-31 20:50

    This actually works pretty well for me in 2.3.8:

    class AudiObserver < ActiveRecord::Observer
      observe :'ActiveRecord::Base'
      #
      # observe methods...
      #
    end
    

提交回复
热议问题