ActionMailer 因“未定义的函数”而失败当因延迟工作而接到电话时

发布于 2024-09-06 14:03:40 字数 260 浏览 3 评论 0原文

因此,如果我尝试直接使用操作邮件程序发送电子邮件,我可以使用所有应用程序帮助程序,例如 url_for、content_for 等,但是当我尝试使用 Delayed_job [send_later] 执行完全相同的操作 [发送电子邮件] 时,我会收到延迟作业失败,未定义的函数 content_for 等,所以就像我的 ActionMailer 中没有加载帮助程序一样。我正在使用rails 2.3.8、active_mailer 2.3.8 和delayed_job 2.0.3

谢谢!!

So if I try sending an email with action mailer directly, I can use all application helpers like url_for, content_for etc, but when I try to do the exact same action [sending email] with delayed_job [send_later] I getting a delayed job fail, of undefined function content_for etc, so it is like no helpers are loaded in my ActionMailer. I am using rails 2.3.8, active_mailer 2.3.8 and delayed_job 2.0.3

Thanks!!

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

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

发布评论

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

评论(1

七月上 2024-09-13 14:03:40

您的问题是您的 sw 不是 ActionView 的子级,因为您的 sw 不是由于 Web 请求而启动的。相反,您的 sw 是由 DelayedJob 机制启动的。

解决方案:创建并使用您自己的 ActionView 实例 --

action_view = ActionView::Base.new # used for calling helper tags, eg link_to
html = action_view.link_to(link_text, url)
# etc...

Your problem is that your sw is not a child of ActionView since your sw is not being initiated as a result of a web request. Rather, your sw is being initiated by the DelayedJob machinery.

Solution: create and use your own instance of ActionView --

action_view = ActionView::Base.new # used for calling helper tags, eg link_to
html = action_view.link_to(link_text, url)
# etc...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文