AcriveRecord (2.2.0) after_update callback and database transaction

Hi,

Does anyone know how can I execute some bit of code after transaction
wrapping up activerecord update/save methods completed?

after_update and after_save filters are both wrapped into the same
transaction, and I need to make external service (druby) aware of
changes immediately after changes were made. Now - I use separate
thread and sleep(1) in druby service to make it see changes, but it’s
not good enough solution. Any ideas how can do it?

Thanks,
Hubert

Hubert £êpicki wrote:

Does anyone know how can I execute some bit of code after transaction
wrapping up activerecord update/save methods completed?

after_update and after_save filters are both wrapped into the same
transaction, and I need to make external service (druby) aware of
changes immediately after changes were made. Now - I use separate
thread and sleep(1) in druby service to make it see changes, but it’s
not good enough solution. Any ideas how can do it?

Like you, I’ve used the sleep hack, because ActiveRecord
doesn’t currently have after_commit callbacks.

The only other solution would be to move the remote
call to your controller, after the transaction block
or save call. You can still leave the details of the
remote call in the model, but just call it from the controller.


Rails Wheels - Find Plugins, List & Sell Plugins -
http://railswheels.com