Extension of answer @ jefflunt.
I added a migration to create a table containing completed tasks
class CreateCompletedJobs < ActiveRecord::Migration def change create_table :completed_jobs do |t| t.integer "priority", :default => 0 t.integer "attempts", :default => 0 t.text "handler", :limit => 2147483647 t.datetime "run_at" t.datetime "completed_at" t.string "queue" t.timestamps end end end
Then the module
class CompletedJob < ActiveRecord::Base end
Finally, a hook has been added to the task I want to save
def success job save_completed_job job end private def save_completed_job job CompletedJob.create({ priority: job.priority, attempts: job.attempts, handler: job.handler, run_at: job.run_at, completed_at: DateTime.now, queue: job.queue }) end
Since I have more than one task, I put the success method in the module and included it in all the tasks that I would like to save. (Note: some of them should not be stored)
natedavisolds
source share