Delayed_job:NoMethodError:未定义方法“my_method_without_delay”
使用rails 2.3.11和delayed_job 2.0.4作为gem,在使用handle_asynchronously
时出现错误:
在我的ActionMailer模型中,我删除了my_method并在声明后立即添加了“handle_asynchronously:my_method”:
class MailSender < ActionMailer::Base
def my_method
...
end
handle_asynchronously :my_method
end
调用时MailSender.deliver_my_method
任务已正确添加到队列中。但是,当尝试处理它时,它失败并显示错误消息:
undefined method `rappel_email_without_delay' for #<YAML::Object:0x1034b85f8>
使用 MailSender.delay.deliver_my_method
进行延迟正在工作,并且任务已正确处理 - 但我宁愿使用 handle_asynchronously
联合国我的模型,以确保邮件始终在后台发送......
Using rails 2.3.11 and delayed_job 2.0.4 as a gem I get an error when using handle_asynchronously
:
In my ActionMailer model, I delcared my_method and added ' handle_asynchronously :my_method' right after the declaration :
class MailSender < ActionMailer::Base
def my_method
...
end
handle_asynchronously :my_method
end
When calling MailSender.deliver_my_method
the task is correctly added to the queue. But when trying to process it, it fails with the error message :
undefined method `rappel_email_without_delay' for #<YAML::Object:0x1034b85f8>
Delaying with MailSender.delay.deliver_my_method
is working and the task correctly processed - But i'd rather use handle_asynchronously
un my model to ensure mail are always sent in the background...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要使用以下命令重新启动工作进程
You need to restart the worker processes using
在3.2.3中也有这个问题。
通过在每次代码更改后重新启动 DJ 进程来修复此问题。
Also had this problem in 3.2.3.
Fixed it by restarting the DJ process after every code change.
您仍然可以使用handle_asynchronously 宏进行声明,但是使用ActionMailer 调用延迟作业的语法有点不同。
这是从旧版本的自述文件中提取的,但它不在当前版本中,所以也许延迟作业的新版本可以解决这个细微差别。
You can still declare using the handle_asynchronously macro, but the syntax for calling delayed jobs with ActionMailer is a bit different.
This was pulled from an older version of the README, but it's not in the current one, so maybe a newer version of delayed jobs worked around this nuance.
我遇到了同样的问题,最终遇到了以下帖子 。基本上,delayed_job 工作人员似乎在解组非 ActiveRecord 对象时遇到困难。对我有用的快速修复方法是要求您的类位于初始化程序或environment.rb中,例如
I ran into the same problem and eventually came across the following post. Basically the delayed_job worker seems to have difficulties unmarshalling non-ActiveRecord objects. The quick fix which worked for me is to require your class in an initializer or environment.rb, e.g.