arproxy
arproxy copied to clipboard
Avoid eager loading `ActiveRecord::Base`
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
I understand the problem but I believe this can be resolved using Railtie API. Have you considered that?