Rails redirect_to w/ post 数据(不是获取)
在rails中,有没有办法执行包含POST数据的重定向?
我正在将一个旧网站移动到 Rails 应用程序,旧网站有很多链接指向很多非 DRY 页面,这些页面在加载后立即使用 javascript 将 XML 数据发布到另一个网站。不是很优雅(或便携)。
由于目标页面位于另一个网站(我们无法控制)上,因此我的选择受到限制,例如我不能仅将数据存储在 cookie 中。
Sys:Rails 2.3.5,Ruby 1.8.6
(是的,我可以在每个相关页面上放置一个隐藏表单,并更改每个链接的操作以将表单数据提交到相关目的地,但我宁愿通过捕获中间请求并从控制器执行重定向来进行更少(并且更少恼人)的更改。)
In rails, is there a way to execute a redirect that includes POST data?
I'm moving an old website to a rails app, and the old website has a lot of links pointing to a lot of non-DRY pages which use javascript, immediately upon loading, to post XML data to another website. Not very elegant (or portable).
Since the destination page is on another website (which we don't control), my options are limited, e.g. I can't just store the data in a cookie.
Sys: Rails 2.3.5, Ruby 1.8.6
(Yes, I could put a hidden form on each of the pages in question, and change the action of each of the links to submit the form data to the pertinent destination, but I would rather make fewer (and less irritating) changes, by catching the intermediate requests and executing a redirect from a controller.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简短回答:是的,
redirect_to 'new url', :status => 307
长答案:参见 http://ilia.ws/ archives/152-Cross-Domain-POST-Redirection.html
有人说它不起作用,但我刚刚检查过,它在 FF/Chrome/IE 中起作用。
Short answer: yes, do
redirect_to 'new url', :status => 307
Long answer: see http://ilia.ws/archives/152-Cross-Domain-POST-Redirection.html
Some people say it doesn't work, but I've just checked and it does in FF/Chrome/IE.