ActiveRecord Global Callbacks for all Models

前端 未结 5 862
清酒与你
清酒与你 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:45

    This seemed to work for me:

    ActiveRecord::Base.after_save do
       ...
    end
    

    Is there a problem I'm not seeing?

提交回复
热议问题