AnA*_*ice 4 ruby-on-rails delayed-job ruby-on-rails-3
我正在努力学习如何在我的rails 3 + heroku app上使用delayed_job.
我目前有一个电子邮件请求(不是延迟工作),但它的工作原理!
UserMailer.conversation_notification(record.commentable, participant, record, @comments).deliver
Run Code Online (Sandbox Code Playgroud)
我更新了这个以开始使用delayed_job:
Delayed::Job.enqueue UserMailer.conversation_notification(record.commentable, participant, record, @comments).deliver
Run Code Online (Sandbox Code Playgroud)
但是这个错误:"ArgumentError(无法排队不响应执行的项目):"
我也尝试过:
UserMailer.delay.conversation_notification(record.commentable, participant, record, @comments)
Run Code Online (Sandbox Code Playgroud)
但是这个错误:
NoMethodError (undefined method `delay' for UserMailer:Class):
Run Code Online (Sandbox Code Playgroud)
任何delayed_job大师在那里?谢谢
来自docs https://github.com/collectiveidea/delayed_job
你的第二种方法是正确的,它删除了.deliver方法:
UserMailer.delay.conversation_notification(record.commentable, participant, record, @comments)
Run Code Online (Sandbox Code Playgroud)
如果你得到一个未定义的方法delay ,你是否将DelayedJob添加到Gemfile?
gem "delayed_job"
Run Code Online (Sandbox Code Playgroud)
由于包含delayed_job会将"延迟"方法添加到所有内容中.
| 归档时间: |
|
| 查看次数: |
8252 次 |
| 最近记录: |