Have a few cases where it is critically important to flush the output of ‘render’ immediately. For example:
render :text => “OK"
render :text => “ERROR"
# DESPERATELY WANT TO FLUSH OUTPUT HERE!
# Do lots of talking with banks, send out mailers, etc.
Another wrinkle here is we can’t store the customer’s banking information to run as a deferred task. Ideally we just want to say ‘flush the output’ after the ‘if’ block. Even if there’s an exception after the ‘if’ we still don’t want them to get a 500, we want them to get the OK/ERROR.
The problem we have is the people connecting to our app are sometimes timing out (they have a short timeout) and think the order failed when in fact it was recorded, customer was charged, etc. I’m a little hesitant about using Thread.new, but perhaps that’s the only reasonable way to flush the output early?
btw- This is Rails 4.0.x, Apache+Passenger.