From 1c5e2f9b98bc5b50ac990d6f1b0ae9df59580444 Mon Sep 17 00:00:00 2001 From: bughit Date: Fri, 25 Jan 2019 13:32:26 -0500 Subject: document the possibility of app initializers running before gem initilizers and suggest a workaround --- guides/source/configuring.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/guides/source/configuring.md b/guides/source/configuring.md index a727dcd010..a329deb710 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -1239,6 +1239,8 @@ Using Initializer Files After loading the framework and any gems in your application, Rails turns to loading initializers. An initializer is any Ruby file stored under `config/initializers` in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks and gems are loaded, such as options to configure settings for these parts. +NOTE: There is no guarantee that your initializers will run after all the gem initilizers, so any initialization code that depends on a given gem having been initialized should go into a `config.after_initilize` block. + NOTE: You can use subfolders to organize your initializers if you like, because Rails will look into the whole file hierarchy from the initializers folder on down. TIP: While Rails supports numbering of initializer file names for load ordering purposes, a better technique is to place any code that need to load in a specific order within the same file. This reduces file name churn, makes dependencies more explicit, and can help surface new concepts within your application. -- cgit v1.2.3