Adrian Serafin
Adrian Serafin

Reputation: 7715

Ruby, post and redirect

I have situation like this:

The problem is that I want to post and redirect (at the same time) user to this new website www.paymentprovider.com/new_payment. Currently I am using

Net::HTTP.post_form 

Do you know any ways to achieve this?

Upvotes: 1

Views: 1337

Answers (1)

Scott Watermasysk
Scott Watermasysk

Reputation: 652

You cannot do a post and redirect without breaking the internet. :)

If you want to use this workflow, you will need to proxy the request.

As an example:

  1. User submits to /pay
  2. You grab those paramaters and make a request to /new_payment
  3. You can grab the results from /new_payment and send them back to the request in /pay

Since this is all happening locally, the option above would seem to be a waste. If /pay is simply missing some parameters and info could you simply supply them in your view? This way you could have both /pay and /new_payment postback to the same location and use two separate views to handle the initial get request.

Upvotes: 2

Related Questions