Hubert Łępicki
2008-Nov-06 13:04 UTC
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2008-Nov-10 09:16 UTC
Re: AcriveRecord (2.2.0) after_update callback and database transaction
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---