pdfkit 中间件的延迟作业
我在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实上,其他答案所暗示的并不那么简单。
实现 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.
尝试 HireFire Heroku Worker Manager。它将在 Heroku 上使用 Delayed Job 和 Resque 工作人员
try HireFire The Heroku Worker Manager. it will use Delayed Job and Resque workers on Heroku