延迟工作乘客生产未定义方法错误
我正在使用延迟作业版本 2.1.4 和操作邮件程序 3.0.8 在后台发送电子邮件。
UserMailer.delay.newsletter(email)
它在开发和生产 Rails 控制台 方面与我配合得很好。
但是,当从我的现场生产乘客服务器调用它时,它会创建 DJ,但是当该 DJ 运行时,它会抛出
{undefined method `newsletter' for #<Class:0xc08afa0>
我认为问题
有帮助吗?
I am using delayed job version 2.1.4 with action mailer 3.0.8 to send my emails in background.
UserMailer.delay.newsletter(email)
It works with me fine in development and production Rails console.
But when it is called from my live production passenger server, it creates DJ but when this DJ runs, it throws
{undefined method `newsletter' for #<Class:0xc08afa0>
I think the problem
Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题出在使用类方法的生产模式下的rails/passenger,
所以,我做了一个解决方案......我将尝试调用实例方法并避免调用<类方法。
让我们看一个例子;假设我需要在后台调用以下方法..
然后,我创建了一个新类 DelayClassMethod
并可以立即在后台运行该方法
因此,我现在正在后台运行一个 instance 方法,该方法将运行类方法。
另一个例子..
假设我想运行
然后它可以通过
The problem is with rails/passenger in production mode with class methods
So, I made a work around solution... I will try to call instance method and avoid to call class method.
Lets see an example; assuming I need to call the following method in background..
Then, I created a new class DelayClassMethod
and can run the method in background now by
So, I am running an instance method now in background which will run the class method.
Another example..
Assume I want to run
Then it can be run by
我的预感是,您在生产中有多个延迟作业版本。您是否使用捆绑器来启动延迟的作业流程?
我建议在在生产中进行捆绑安装时,我会使用 --binstubs 标志来生成一个包装器elasted_job 并使用该可执行文件来启动作业。
My hunch is that you have multiple versions of the delayed_job in production. Are you using bundler to start your delayed job process?
I would recommend when doing bundle install in production, I would use the --binstubs flag to generate a wrapper around the delayed_job and use that executable to start the jobs.