Rails:将用大虾生成的pdf通过电子邮件发送到ActionMailer发送的电子邮件吗?
我有一个电子商务应用程序。我正在使用 Prawn 生成 pdf 订单发票。我正在使用标准的虾设置。在views/admin/orders中,我有一个名为show.pdf.prawn的文件。当卖家在其管理部分查看订单时,他单击一个链接,打开 PDF 版本的订单/显示视图。这一切都很完美。
现在,棘手的部分。订单完成后,我会向卖家发送一封电子邮件。我想做的是将订单/演出的 pdf 发票版本附加到该电子邮件中。可以这样做吗?有关电子邮件附件的文档非常有限,我无法找到完成我所描述的工作流程的资源。
任何指导表示赞赏。
I have an ecommerce app. I'm using Prawn to generate pdf invoices of orders. I'm using a standard Prawn setup. In views/admin/orders, I have a file called show.pdf.prawn. When the seller is viewing an order in his admin section, he clicks a link that opens the pdf version of the orders/show view. This all works perfectly.
Now, the tricky part. When an order is completed, I send an email to the seller. What I'd like to do is attach the pdf invoice version of orders/show to that email. Is it possible to do this? The documentation on email attachments is pretty limited and I haven't been able to find resources that go through the workflow that I'm describing.
Any guidance is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 ActionMailer 通过电子邮件发送附件相当容易:
您可能遇到的一个问题是在 prawnto 方法之外生成 pdf 文件(当使用 prawnto 插件时)-
如果是这种情况,我强烈建议您使用这种方法 相反。
Sending an attachment with an email is fairly easy with ActionMailer:
One problem you might have with this is generating the pdf file outside of the prawnto method (when using the prawnto plugin)-
If this is is the case I strongly recommend you to use this approach instead.
我遇到了同样的问题,我设法通过从模型生成 pdf 来做到这一点,比评估模板容易得多。我在这里回复了答案:
将 Prawn PDF 保存为回形针附件?
I had the same problem, i managed to do it by generating the pdf from a model, much easier than evaluating the template. I replied with the answer here :
Save a Prawn PDF as a Paperclip attachment?