Rails pass params/arguments to ActiveRecord callback function

前端 未结 4 1368
庸人自扰
庸人自扰 2021-02-05 06:17

I have the snippet below in one of my AR models:

after_update :cache_bust

The cache_bust method in the model accepts a parameter (

4条回答
  •  被撕碎了的回忆
    2021-02-05 06:46

    There are four types of callbacks accepted by the callback macros: Method references (symbol), callback objects, inline methods (using a proc), and inline eval methods (using a string).

    Try this?

    after_update -> { cache_bust(true) }
    

提交回复
热议问题