Delayed_job (2.1.4) error: Job failed to load: instance of IO needed. Handler nil

我与影子孤独终老i 提交于 2019-12-04 19:03:45

Found the solution: my problem was caused by mass-assignment protection. I have an initializer to protect against mass-assignment:

# SECURITY: protect against mass assignment vulnerabilities
# enforces explicitly setting attributes accessible in models (whitelisting)
ActiveRecord::Base.send(:attr_accessible, nil)

This prevented delayed_job to access the handler field! Not sure if this can be considered a bug in DJ. Here is the initializer code that solved my problem:

# Imortant: delayed job requires some attributes to be accessible - make sure they are
Delayed::Job.attr_accessible :priority, :payload_object, :handler, :run_at, :failed_at

It's possible that your handler column is too small for what's being put into it. you can fix this in a migration like so:

change_column :delayed_jobs, :handler, :text, :limit => 64.kilobytes + 1
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!