mardi 6 novembre 2018

Pass newly created object of after_create callback in Rails

Everytime an object has been created i want to enqueue it in a Redis queue to check for certain properties. How can i add the created object directly as a parameter to the callback? Something like? So my redis job would do something like this:

class FurtherProcessCarJob
 #....

 def self.perform(order)
   puts order.id
 end 
end

whereas in the model

after_create Resque.enqueue FurtherProcessCar, #self

It is possible to hook a method to the callback and there look for the car again and the enqueue the object, but is it possible to do it directly?

Aucun commentaire:

Enregistrer un commentaire