Stan Blog

學習過程中的一些記錄

[Rails] Model 內的所有 Callbacks

建立物件 (Creating an Object)

  • before_validation
  • after_validation
  • before_save
  • after_save
  • before_create
  • around_create
  • after_create

更新物件 (Updating an Object)

  • before_validation
  • after_validation
  • before_save
  • after_save
  • before_update
  • around_update
  • after_update

刪除物件 (Destroying an Object)

  • before_destroy
  • after_destroy
  • around_destroy

補充 : after_save 在建立、更新時,都會運作,但是不論宣告的順序為何,after_save 永遠在更特定的 after_createafter_update 的之後才會執行。

Comments

comments powered by Disqus