项目需要把 delayed_job 数据库独立出来,创建完新数据库之后,运行RAILS_ENV=production script/delayed_job start
无反应,新的 DJ 数据库里能加进去数据,RAILS_ENV=production rake jobs:work
能运行,但是会报错说找不到对象,卡了一晚上,谁能帮我看下是哪里写的不对,不胜感激,具体代码如下:
config/initializers/delayed_job_config.rb
Delayed::Job.class_eval do
establish_connection ActiveRecord::Base.configurations["delayed_job"]
end
database.yml
delayed_job:
adapter: mysql2
encoding: utf8
reconnect: false
database: delayed_job
pool: 5
username: root
password: "987654"
host: localhost
my_job.rb
class MyJob < Struct.new(:episode)
def perform
episode.do_something
end
end
DJ 的报错信息提示说找不到 episode,Couldn't find Episode with id=1