pdfkit 中间件的延迟作业

发布于 2024-11-24 02:33:12 字数 204 浏览 7 评论 0原文

我在 Heroku 上使用 pdfkit 中间件来生成 pdf。我怎样才能把生成pdf的东西作为后台工作。

def index

    @products = Product.all

    respond_to do |format|
      format.html
      format.pdf 
    end  

end

I am using pdfkit middleware on Heroku to generate pdf. How can i make pdf generating thing as a background job.

def index

    @products = Product.all

    respond_to do |format|
      format.html
      format.pdf 
    end  

end

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

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

发布评论

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

评论(2

月寒剑心 2024-12-01 02:33:14

事实上,其他答案所暗示的并不那么简单。

实现 PDF 生成的延迟作业一切都很好。但您还有更多事情需要考虑 - 您将流程交给 DJ,最终结果是生成 PDF。但是您必须将该 PDF 返回给用户 - 要么轮询作业何时完成,然后提供可能的 pdf 链接,要么向他们发送电子邮件以收集 PDF。

It's not so simple what the other answers are suggesting in fact.

Implementing delayed job for PDF generation is all well and good. But you have more things to consider - you pass the process over to DJ and the end result is a PDF is generated. But you have to then get that PDF back infront of the user - either by polling the job for when it completes and then providing a link to the pdf possibly, or sending them an email to collect the PDF.

失与倦" 2024-12-01 02:33:14

尝试 HireFire Heroku Worker Manager。它将在 Heroku 上使用 Delayed Job 和 Resque 工作人员

try HireFire The Heroku Worker Manager. it will use Delayed Job and Resque workers on Heroku

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