Andrew Max

Joined

50 Experience
0 Lessons Completed
0 Questions Solved

Activity

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 https://stackoverflow.com/questions/56402093/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
logo Created with Sketch.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

© 2022 GoRails, LLC. All rights reserved.