Ruby,发布和重定向
我遇到这样的情况:
- 用户在 '/pay' 中提交带有
action='/pay'
的表单 - 我必须添加一些附加参数并将发布请求发送到
www. paymentprovider.com/new_ payment问题
是我想将用户发布并重定向(同时)到这个新网站www. paymentprovider.com/new_ payment
。目前我正在使用
Net::HTTP.post_form
你知道有什么方法可以实现这一目标吗?
I have situation like this:
- user submits form with
action='/pay'
- in '/pay' I have to add some additional parameters and send post request to
www.paymentprovider.com/new_payment
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法在不中断互联网的情况下进行发布和重定向。 :)
如果您想使用此工作流程,您将需要代理该请求。
举个例子:
由于这一切都发生在本地,因此上面的选项似乎成为废物。如果 /pay 只是缺少一些参数和信息,您可以简单地在您看来提供它们吗?这样,您就可以将 /pay 和 /new_ payment 回发到同一位置,并使用两个单独的视图来处理初始获取请求。
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:
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.