Custom callback

  • How to implement a custom call_back and then register the method in an observer?

  • If we use a transaction in the model, is after_create triggered for each individual record within the transaction, or is it run after the transaction is completed?

Using Rails 3

thanks

+4
source share
1 answer
  • You add a method, say after_something to your observer, and then issue notify_observers (: after_something) to your code in the model. The method will receive an instance of the model as a parameter.

  • after_create is called for the observer of the class whose instance was created. Each instance.

+9
source

Source: https://habr.com/ru/post/1339819/


All Articles