What is the difference between `after_create` and `after_save` and when to use which?

后端 未结 3 466
独厮守ぢ
独厮守ぢ 2020-12-04 15:19

Are after_create and after_save the same as per functionality?

I want to do an operation with the email of a user after its account creatio

3条回答
  •  借酒劲吻你
    2020-12-04 15:37

    after_create only works once - just after the record is first created.

    after_save works every time you save the object - even if you're just updating it many years later

    So if you want to do this email operation only just the once (and then never again) then use after_create.

    If you want to do it every time the object is saved, then do it in after_save

提交回复
热议问题