Here is what you need to know. When you add a DelayedJob stone to your application, you create a migration for it to create a table in which tasks are stored, but you do not create a model. This is because DelayedJob already has a model included in the gem (i.e. Delayed::Job ). You need to fix this model a bit, as well as your own models. You can do this in the initializer.
You may already have an initializer for configuring DelayedJob if you can do it there if you don't need to create one. So, create your initializer (in config/initializers ), if you donβt have one, call it delayed_job_config.rb , add the following to it:
Delayed::Job.class_eval do establish_connection ActiveRecord::Base.configurations["#{Rails.env}"] end
We did the same thing with the DelayedJob model that you did with your own models. Now DelayedJob will use this connection to place tasks in the database.
skorks
source share