how do i get my app database info only after another server has called my app''s method and updated my app''s database? Now, i can just get the database info before anther server calls my app''s method. def one some code two some code end def two calls another server''s methods and sends my app ping url(http:// myhost/.../three) that will be automaticlly called by that server after executing the two method end def three another server calls this method and updates database end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I need your help!Thanks! On Apr 16, 11:03 am, daociyiyou <chey...-/E1597aS9LRv1O+Z8WTAqQ@public.gmane.org> wrote:> how do i get my app database info only after another server has > called my app''s method and > updated my app''s database? Now, i can just get the database info > before anther server calls my app''s method. > > def one > some code > two > some code > end > > def two > calls another server''s methods and sends my app ping url(http:// > myhost/.../three) that will be automaticlly called by that server > after executing the two method > end > > def three > another server calls this method and updates database > end--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It seems i have not show the question very clear. While my app codes is accessing the db,anohter server is updating the db. so What i want is not accessing the db until the db is updated.I think there must be a ruby or rails method to do it, but can not find it. Thanks! On Apr 16, 2:12 pm, daociyiyou <chey...-/E1597aS9LRv1O+Z8WTAqQ@public.gmane.org> wrote:> I need your help!Thanks! > > On Apr 16, 11:03 am, daociyiyou <chey...-/E1597aS9LRv1O+Z8WTAqQ@public.gmane.org> wrote: > > > how do i get my app database info only after another server has > > called my app''s method and > > updated my app''s database? Now, i can just get the database info > > before anther server calls my app''s method. > > > def one > > some code > > two > > some code > > end > > > def two > > calls another server''s methods and sends my app ping url(http:// > > myhost/.../three) that will be automaticlly called by that server > > after executing the two method > > end > > > def three > > another server calls this method and updates database > > end--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
hi,any one help me? On 4月16日, 下午6时00分, daociyiyou <chey...@yahoo.com.cn> wrote:> It seems i have not show the question very clear. > While my app codes is accessing the db,anohter server is updating the > db. > so What i want is not accessing the db until the db is updated.I think > there must be a ruby or rails method to do it, but can not find it. > Thanks! > > On Apr 16, 2:12 pm, daociyiyou <chey...-/E1597aS9LRv1O+Z8WTAqQ@public.gmane.org> wrote: > > > I need your help!Thanks! > > > On Apr 16, 11:03 am, daociyiyou <chey...-/E1597aS9LRv1O+Z8WTAqQ@public.gmane.org> wrote: > > > > how do i get my app database info only after another server has > > > called my app''s method and > > > updated my app''s database? Now, i can just get the database info > > > before anther server calls my app''s method. > > > > def one > > > some code > > > two > > > some code > > > end > > > > def two > > > calls another server''s methods and sends my app ping url(http:// > > > myhost/.../three) that will be automaticlly called by that server > > > after executing the two method > > > end > > > > def three > > > another server calls this method and updates database > > > end--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
2009/4/16 daociyiyou <cheyu22-/E1597aS9LRv1O+Z8WTAqQ@public.gmane.org>:> > hi,any one help me? > > On 4月16日, 下午6时00分, daociyiyou <chey...@yahoo.com.cn> wrote: >> It seems i have not show the question very clear. >> While my app codes is accessing the db,anohter server is updating the >> db. >> so What i want is not accessing the db until the db is updated.I think >> there must be a ruby or rails method to do it, but can not find it. >> Thanks! >> >> On Apr 16, 2:12 pm, daociyiyou <chey...-/E1597aS9LRv1O+Z8WTAqQ@public.gmane.org> wrote: >> >> > I need your help!Thanks! >> >> > On Apr 16, 11:03 am, daociyiyou <chey...-/E1597aS9LRv1O+Z8WTAqQ@public.gmane.org> wrote: >> >> > > how do i get my app database info only after another server has >> > > called my app''s method and >> > > updated my app''s database? Now, i can just get the database info >> > > before anther server calls my app''s method. >> >> > > def one >> > > some code >> > > two >> > > some code >> > > end >> >> > > def two >> > > calls another server''s methods and sends my app ping url(http:// >> > > myhost/.../three) that will be automaticlly called by that server >> > > after executing the two method >> > > end >> >> > > def three >> > > another server calls this method and updates database >> > > endBecause of the way Rails is usually deployed, this will be very difficult. When Rails is first called and the code starts to execute, it is in instance #1 It then runs through the code and calls a method that invokes the remote service. (now you want it to wait) When the remote service calls back, because instance #1 is busy, it will invoke the method on instance #2 which has no knowledge of instance #1 or it''s waiting. Two quick ways I can think of to solve this. 1. Don''t let the remote service update the database, get it to return the data and you update the database within the same method call so you''re always in control 2. If that''s not possible, return from the method and use AJAX or a page refresh to check if the remote service has done what it should and display the results after that. Andrew Timberlake http://ramblingsonrails.com http://www.linkedin.com/in/andrewtimberlake "I have never let my schooling interfere with my education" - Mark Twain --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
thanks.It seems i can not use active record callback. On 4月16日, 下午8时22分, Andrew Timberlake <and...@andrewtimberlake.com> wrote:> 2009/4/16 daociyiyou <chey...-/E1597aS9LRv1O+Z8WTAqQ@public.gmane.org>: > > > > > > > hi,any one help me? > > > On 4月16日, 下午6时00分, daociyiyou <chey...@yahoo.com.cn> wrote: > >> It seems i have not show the question very clear. > >> While my app codes is accessing the db,anohter server is updating the > >> db. > >> so What i want is not accessing the db until the db is updated.I think > >> there must be a ruby or rails method to do it, but can not find it. > >> Thanks! > > >> On Apr 16, 2:12 pm, daociyiyou <chey...-/E1597aS9LRv1O+Z8WTAqQ@public.gmane.org> wrote: > > >> > I need your help!Thanks! > > >> > On Apr 16, 11:03 am, daociyiyou <chey...-/E1597aS9LRv1O+Z8WTAqQ@public.gmane.org> wrote: > > >> > > how do i get my app database info only after another server has > >> > > called my app''s method and > >> > > updated my app''s database? Now, i can just get the database info > >> > > before anther server calls my app''s method. > > >> > > def one > >> > > some code > >> > > two > >> > > some code > >> > > end > > >> > > def two > >> > > calls another server''s methods and sends my app ping url(http:// > >> > > myhost/.../three) that will be automaticlly called by that server > >> > > after executing the two method > >> > > end > > >> > > def three > >> > > another server calls this method and updates database > >> > > end > > Because of the way Rails is usually deployed, this will be very difficult. > When Rails is first called and the code starts to execute, it is in instance #1 > It then runs through the code and calls a method that invokes the > remote service. > (now you want it to wait) > When the remote service calls back, because instance #1 is busy, it > will invoke the method on instance #2 which has no knowledge of > instance #1 or it''s waiting. > > Two quick ways I can think of to solve this. > 1. Don''t let the remote service update the database, get it to return > the data and you update the database within the same method call so > you''re always in control > 2. If that''s not possible, return from the method and use AJAX or a > page refresh to check if the remote service has done what it should > and display the results after that. > > Andrew Timberlakehttp://ramblingsonrails.comhttp://www.linkedin.com/in/andrewtimberlake > > "I have never let my schooling interfere with my education" - Mark Twain--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---