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

Requiring delayed_job_active_record loads ActiveRecord::Base, which breaks Rails initialization #239

Open
jpalermo opened this issue Aug 31, 2024 · 0 comments

Comments

@jpalermo
Copy link

Some additional context in this Rails issue.

Essentially when you require delayed_job_active_record, since it has a class that inherits from ActiveRecord::Base, it causes the Rails class loader to initialize ActiveRecord which causes some parts of Rails to then not be configurable.

I was pointed to this guide which recommends using the on_load hooks of ActiveSupport:

ActiveSupport.on_load(:active_record) do
  DEFINE Delayed::Backend::ActiveRecord::Job < ::ActiveRecord::Base here
end

This will cause the block to get loaded after Rails initializes ActiveRecord

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

No branches or pull requests

1 participant