2009/4/16 daociyiyou firstname.lastname@example.org:
another server calls this method and updates database
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
It then runs through the code and calls a method that invokes the
(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.
- 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
- 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.
“I have never let my schooling interfere with my education” - Mark Twain