4

At work, we both have an Rails application 'MyApplication' and an gem/ engine 'MyEngine' which provides utilities to MyApplication. One of the purposes of MyEngine is to monkey patch ruby base classes and extend them with functionality relevant to MyApplication (e.g. stored in my_engine/app/monkeys/kernel.rb).

With our current rails 5.2.3 setup, all works fine with the following engine configuration:

#lib/my_engine/engine.rb

module MyEngine
  class Engine < ::Rails::Engine  
    config.eager_load_paths << "app/monkeys"
  end
end

But when hooking up the engine to a new rails 6.1.0 version of MyApplication, the classes no longer are eager_loaded and the monkey patched methods yield an undefined method NoMethodError.

I know that rails 6.0 and upwards made the change to use Zeitwerk for autoloading and eager loading constants, but days into this mess I am unfortunately still not capable of configuring my engine in such way that it actually works with rails 6.1.0. Any help, or advice in de broadest sense, would be much, much appreciated!

Jurr
  • 41
  • 3

0 Answers0