How to run rails initialization code that relies on all classes being loaded?

364 Views Asked by At

I have some crucial application setup code that I want to run once on application spinup that requires iterating through classes of a certain type and calling a gem specific initialize method on them.

According to How can I preload concerns in a rails initializer using Rails 6/Zeitwerk? I should not autoload constants in initializers.

So how can I run code once on application load after classes are loaded

I tried with no luck:

    config.after_initialize do
      # do stuff
    end
0

There are 0 best solutions below