collectiveidea / delayed_job

Database based asynchronous priority queue system -- Extracted from Shopify
http://groups.google.com/group/delayed_job
MIT License
4.81k stars 955 forks source link

Check Rails is defined before referring to Rails #1145

Open bazay opened 3 years ago

bazay commented 3 years ago

https://github.com/collectiveidea/delayed_job/blob/baed6e813870e1144e7a4291bc71e06a67a533de/lib/delayed/worker.rb#L119

We are running a rack application (not Rails) that uses DelayedJob as well as loads in ActionDispatch i.e.

spec.add_dependency 'actionpack'
spec.add_dependency 'delayed_job'
...
require 'action_dispatch'
require 'delayed_job'

The linked line of code causes our application to blow up because the Rails class is not defined.

Is there a reason why this is checking ActionDispatch::Reloader and not the Rails class constant itself?

Perhaps it should check both are defined?