Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ago isn't a method on Integers in ActiveSupport? #1272

Open
aviemet opened this issue Mar 1, 2024 · 5 comments
Open

ago isn't a method on Integers in ActiveSupport? #1272

aviemet opened this issue Mar 1, 2024 · 5 comments

Comments

@aviemet
Copy link

aviemet commented Mar 1, 2024

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.

@bensheldon
Copy link
Owner

That's odd. Can you share a link to it being removed?

@aviemet
Copy link
Author

aviemet commented Mar 1, 2024

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

@bensheldon
Copy link
Owner

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

@aviemet
Copy link
Author

aviemet commented Mar 1, 2024

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.

@tjkorthal
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Inbox
Development

No branches or pull requests

3 participants