Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails observer custom callback

  1. How to implement custom call_back and then register method into observer?

  2. If we use transaction into the model, is after_create is triggered for every single record inside the transaction or is triggered after transaction is finished?

Using Rails 3

Thanks

like image 444
alex Avatar asked Dec 29 '22 01:12

alex


1 Answers

  1. You add the method, say, :after_something to your observer, and then issue notify_observers(:after_something) in your code in model. The method will receive the model instance as a parameter.

  2. after_create is called for the observer of the class which instance was created. Each instance.

like image 168
Roman Avatar answered Jan 13 '23 07:01

Roman