From 516aa3d4a7c1b627462182ff0309c726c0417ab8 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Tue, 11 May 2021 15:32:33 +0200 Subject: [PATCH] Register modules after app initialization If we do this earlier, Zeitwerk will autoload files from other engines. This, in turn, leads to configuration from the local app's `config/initializers` directory not being respected when loading files from those other engines. Case in point: When configuring Solidus' order state machine in Solidus 2.11 using `Spree::Config.state_machines.order = "MyOrderStateMachineModule"`, and this change is not in the gem, Solidus' `Spree::Order` class is loaded, and the wrong module is included. --- config/initializers/alchemy.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/initializers/alchemy.rb b/config/initializers/alchemy.rb index 54dde80..be724de 100644 --- a/config/initializers/alchemy.rb +++ b/config/initializers/alchemy.rb @@ -52,4 +52,6 @@ end end -Alchemy::Modules.register_module(alchemy_module) +Rails.application.config.after_initialize do + Alchemy::Modules.register_module(alchemy_module) +end