Skip to content

Instantly share code, notes, and snippets.

@tkhk
Created April 8, 2022 10:42
Show Gist options
  • Save tkhk/c6cbdac06624238fb7f11dbfdb6b4467 to your computer and use it in GitHub Desktop.
Save tkhk/c6cbdac06624238fb7f11dbfdb6b4467 to your computer and use it in GitHub Desktop.
Rails の起動プロセスの順番

Rails の起動プロセスの順番

毎回忘れるのでメモ

  # == Booting process
  #
  # The application is also responsible for setting up and executing the booting
  # process. From the moment you require "config/application.rb" in your app,
  # the booting process goes like this:
  #
  #   1)  require "config/boot.rb" to set up load paths
  #   2)  require railties and engines
  #   3)  Define Rails.application as "class MyApp::Application < Rails::Application"
  #   4)  Run config.before_configuration callbacks
  #   5)  Load config/environments/ENV.rb
  #   6)  Run config.before_initialize callbacks
  #   7)  Run Railtie#initializer defined by railties, engines and application.
  #       One by one, each engine sets up its load paths, routes and runs its config/initializers/* files.
  #   8)  Custom Railtie#initializers added by railties, engines and applications are executed
  #   9)  Build the middleware stack and run to_prepare callbacks
  #   10) Run config.before_eager_load and eager_load! if eager_load is true
  #   11) Run config.after_initialize callbacks

https://github.com/rails/rails/blob/de53ba56cab69fb9707785a397a59ac4aaee9d6f/railties/lib/rails/application.rb#L43-L60

特に environments と initializers について config/environments/ENV.rb -> initializers の順

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment