What is purpose of around_create callback in Rails Model?

前端 未结 6 1996
野的像风
野的像风 2021-02-05 15:42

when is around_create callback code executed, in what situations we should use it?

6条回答
  •  旧时难觅i
    2021-02-05 16:09

    around_create is called when a model with the new? flag is saved. It can be used to add data to add/change values of the model, call other methods, etc... I cannot thnk of a specific use case for this call-back but it completes a set of "before, after, around" call-backs for the create action. There is a similar "before, after, around" call back set for the find, update, save, and delete events.

提交回复
热议问题