# AcriveRecord (2.2.0) after\_update callback and database transaction

**URL:** <https://www.ruby-forum.com/t/acriverecord-2-2-0-after-update-callback-and-database-transaction/152691>\
**Category:** Rails\
**Created:** [November 6, 2008, 2:04pm UTC](https://www.ruby-forum.com/t/acriverecord-2-2-0-after-update-callback-and-database-transaction/152691 "2008-11-06T14:04:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hubert\_SSSSSSSSSpic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/73ab20/32.png) [@Hubert\_SSSSSSSSSpic](https://www.ruby-forum.com/u/Hubert_SSSSSSSSSpic)\
**Post date:** [November 6, 2008, 2:04pm UTC](https://www.ruby-forum.com/t/acriverecord-2-2-0-after-update-callback-and-database-transaction/152691/1 "2008-11-06T14:04:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Hubert\_SSSSSSSSSpic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/73ab20/32.png) [@Hubert\_SSSSSSSSSpic](https://www.ruby-forum.com/u/Hubert_SSSSSSSSSpic)\
**Post date:** [November 10, 2008, 10:16am UTC](https://www.ruby-forum.com/t/acriverecord-2-2-0-after-update-callback-and-database-transaction/152691/2 "2008-11-10T10:16:55Z")

</div>

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](http://railswheels.com)
