good_job
good_job copied to clipboard
`ago` isn't a method on Integers in ActiveSupport?
I just installed good_job
to try it out, and upon running server
for the first run, I was confronted with a looping wall of errors. It looks like there's a transactional database call that's failing and retrying infinitely due to the following error:
[GoodJob] Notifier errored: NoMethodError: undefined method 'ago' for 30:Integer
located in good_job-3.26.1/app/models/good_job/process.rb:135
Some light Googling suggests ago
was removed from ActiveSupport at some point, and trying 30.seconds.ago
in the Rails console also fails with the same message.
That's odd. Can you share a link to it being removed?
I dove a bit further into it, and it appears that changing the way the duration variables are defined fixes the issue.
30.seconds
and 5.minutes
return an integer, which doesn't have an ago
method. Changing them to singular calls makes them return a duration, which does have the ago
method. So, at least for me, starting at line 11 on the process.rb
file, this fix seems to have worked for now:
# Interval until the process record being updated
STALE_INTERVAL = 30.second # singularized it
# Interval until the process record is treated as expired
EXPIRED_INTERVAL = 5.minute # singularized it
Not sure if that's an actual fix, or if I just somehow have something weird going on with ActiveSupport
in my project
I think something strange is going on with your ActiveSupport. I think this is where Rails patches Numerics with seconds
:
https://github.com/rails/rails/blob/5cedb8745cb7d5cf8dade94737095458110df2ed/activesupport/lib/active_support/core_ext/numeric/time.rb#L13-L15
If second
works in your project, it's likely something else in your project is monkeypatching Integers#seconds
Shoot, ok. That sounds like it might be a nightmare to track down. Thank you for your input, I'll try to figure out what's going on in my project.
I just ran into the same issue. My app is running in a stripped-down API mode, and ActiveJob wasn't being loaded. After uncommenting require "active_job/railtie"
in config/application.rb
it ran just fine.
When creating a new project, Rails configs (e.g. config/environments/{development/test/production}.rb
) now include lines like this:
require 'active_support/core_ext/integer/time'
Maybe you need to do add that? @aviemet