2

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
Andrew
  • 942
  • 10
  • 26

0 Answers0