在我的Rails应用程序(4.2.4)中,我一直在尝试让异步邮件发送正常工作。
我安装了delayed_job作为我的队列适配器,并在几个地方设置它作为适配器:config/application.rb,config/environments/{development,production}.rb和config/initializers/active_job.rb。 安装: 我将以下内容添加到我的Gemfile中:
在config/application.rb、config/environments/production.rb和config/environments/development.rb中:
在config/initializers/active_job.rb文件中(当上述方法无效时添加):
在config/application.rb中,我遇到了相同的错误和堆栈跟踪。
我安装了delayed_job作为我的队列适配器,并在几个地方设置它作为适配器:config/application.rb,config/environments/{development,production}.rb和config/initializers/active_job.rb。 安装: 我将以下内容添加到我的Gemfile中:
gem 'delayed_job_active_record'
接下来,我运行了以下命令:
$ bundle install
$ rails generate delayed_job:active_record
$ rake db:migrate
$ bin/delayed_job start
在config/application.rb、config/environments/production.rb和config/environments/development.rb中:
config.active_job.queue_adapter = :delayed_job
在config/initializers/active_job.rb文件中(当上述方法无效时添加):
ActiveJob::Base.queue_adapter = :delayed_job
我还运行了一个针对延迟作业(delayed_job)的ActiveRecord迁移,并在运行服务器之前启动了bin/delayed_job。
话虽如此,但每当我尝试:
UserMailer.welcome_email(@user).deliver_later(wait: 1.minutes)
I get the following error:
NotImplementedError (Use a queueing backend to enqueue jobs in the
future. Read more at http://guides.rubyonrails.org/active_job_basics.html):
app/controllers/user_controller.rb:25:in `create'
config.ru:25:in `call'
我认为delayed_job是一个队列后端...我有什么遗漏的吗?
编辑:
我也无法让sucker_punch工作。当在bundler中安装sucker_punch,并使用:
config.active_job.queue_adapter = :sucker_punch
在config/application.rb中,我遇到了相同的错误和堆栈跟踪。
`gem 'delayed_job_active_record'`,`bundle install`
然后,运行了以下命令:`rails generate delayed_job:active_record`, `rake db:migrate`, `bin/delayed_job start`, `rails server`
- Anish Goyalapplication.rb
,如果有每个环境的话就不用了。在设置 sucker_punch 之前,让我们先修复 delayed_job。 - Leonel Galán