2017年8月22日 星期二

rails 可以自己定義 model callback

滿實用的,但應該少用,正常的 lifecycle 能夠滿足就不應該增加新的東西

想到最有可能會用的的地方就是搭配 sub/pub design pattern 的時候,例如 publish 後要 broadcast `published` event

http://vinsol.com/blog/2014/07/07/custom-model-callbacks-in-rubyonrails/

沒有留言:

張貼留言