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

Avoid eager loading ActiveRecord::Base #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yujideveloper
Copy link

Problem

When Arproxy is loaded by specifying Gemfile, require "active_record/base" is called and ActiveRecord::Base is loaded.
Just when Rails.application.config.active_record.xxx are copied to ActiveRecord::Base.xxx.
So, config/initializers/new_framework_defaults_x_x.rb does not work well.

This PR's solution

Arproxy avoid eager loading ActiveRecord::Base, and defer proxy_chain.enable! call until ActiveRecord::Base is loaded.

Other solution

I thought following solution, but it is a bit tricky. I think this PR's solution is easier for gem users.

# Gemfile
gem "arproxy", require: false
# config/initializers/arproxy.rb
Rails.configuration.after_initialize do # or on_prepare
  require "arproxy"

  # setup arproxy...
end

@sorah
Copy link
Member

sorah commented Feb 3, 2022

I understand the problem but I believe this can be resolved using Railtie API. Have you considered that?

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

Successfully merging this pull request may close these issues.

2 participants