Forum: Ruby on Rails how to ensure

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
daociyiyou (Guest)
on 2009-04-16 07:04
(Received via mailing list)
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
  some code

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

def three
  another server calls this method and updates database
daociyiyou (Guest)
on 2009-04-16 10:12
(Received via mailing list)
I need your help!Thanks!
daociyiyou (Guest)
on 2009-04-16 14:01
(Received via mailing list)
It seems i have not show the question very clear.
While my app codes is accessing the db,anohter server is updating the
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.
daociyiyou (Guest)
on 2009-04-16 15:32
(Received via mailing list)
hi,any one help me?
Andrew T. (Guest)
on 2009-04-16 16:23
(Received via mailing list)
2009/4/16 daociyiyou <removed_email_address@domain.invalid>:
>> > > end
>> > > def three
>> > >   another server calls this method and updates database
>> > > end

Because of the way Rails is usually deployed, this will be very
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 T.

"I have never let my schooling interfere with my education" - Mark Twain
daociyiyou (Guest)
on 2009-04-16 20:39
(Received via mailing list)
thanks.It seems i can not use active record callback.

On 4ÔÂ16ÈÕ, ÏÂÎç8ʱ22·Ö, Andrew T. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.