Rails 3 文件下载向导

发布于 2024-12-02 10:59:43 字数 241 浏览 4 评论 0原文

我编写了一个应用程序,可引导您完成两步向导 - 一个页面收集信息,另一个页面是协议。当您单击“同意”时,页面会加载“正在下载此文件...”页面,然后应该开始实际下载文件,总的来说,这是一个非常常见的任务。然而,我正在努力寻找 Rails 中的解决方案。理想情况下,我认为只渲染“正在下载页面...”,然后调用 send_file,但您不能这样做,因为它会导致 DoulbeRender 错误。

在 Rails 中加载页面然后启动文件下载的好方法是什么?

I wrote an app that takes you through a 2 step wizard - one page collects information, the other is an agreement. When you click Agree the page loads a "Downloading this file..." page, and then should start actually downloading the file, overall a pretty common task. However, I'm struggling with a solution in Rails. Ideally I would think to just render the "Downloading page..." and then make a call to send_file, but you can't do this as it results in a DoulbeRender error.

What is a good way to load a page and then subsequently initiate a file download in Rails?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瞳孔里扚悲伤 2024-12-09 10:59:43

您想要呈现下载页面,然后将用户发送到发送文件的单独操作。通常,这是通过元标记完成的,请参阅触发页面上的文件下载包含 PHP 示例的内容

You want to render the download page, and then send the user to a separate action which sends your file. Generally this is accomplished with a meta tag, see Trigger file download on a page with content for a PHP example.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文