ejschmitt / delayed_job_web

Resque like web interface for delayed job
MIT License
478 stars 188 forks source link

NoMethodError - undefined method `update_attributes' for Delayed::Backend::ActiveRecord::Job #118

Closed atstockland closed 3 years ago

atstockland commented 3 years ago

After upgrading to Rails 6.1 I'm experiencing the following error when attempting to "retry" or "reload" a failed job via the web interface.

 2020-12-23 19:13:30 - NoMethodError - undefined method `update_attributes' for #.     <Delayed::Backend::ActiveRecord::Job:0x00005562374ee528>
 2020-12-23T19:13:30.300691+00:00 app[web.1]: Did you mean?  update_attribute:
 2020-12-23T19:13:30.300692+00:00 app[web.1]: /app/vendor/bundle/ruby/2.7.0/gems/activemodel-6.1.0/lib/active_model/attribute_methods.rb:469:in `method_missing'
 2020-12-23T19:13:30.300694+00:00 app[web.1]: /app/vendor/bundle/ruby/2.7.0/gems/delayed_job_web-1.4.3/lib/delayed_job_web/application/app.rb:155:in `block in <class:DelayedJobWeb>'

This error originates in the following delayed_job_web code found in /lib/delayed_job_web/application/app.rb:155

 post "/reload/:id" do
   job = delayed_job.find(params[:id])
  job.update_attributes(:run_at => Time.now, :failed_at => nil, :locked_by => nil, :locked_at => nil, :last_error => nil, :attempts => 0)
  redirect back
 end

I suspect simply changing job.update_attributes to job.update would fix this. I'd be happy to submit a PR if you concur.

atstockland commented 3 years ago

I created a branch that simply changed update_attributes to update. Delayed Job Web in my app is functioning properly, again. https://github.com/atstockland/delayed_job_web

ClaytonPassmore commented 3 years ago

@atstockland can this be closed now that your changes were merged in #119? (Thank you for fixing by the way!)