Rails initializer 的載入順序
2016-10-20 10:39
1 minute read

如果 rails app 裡的 initializer 有載入順序的需求的話

可以照著 Ruby On Rails Guide 這篇來設定

If you have any ordering dependency in your initializers, you can control the load order through naming. Initializer files are loaded in alphabetical order by their path. For example, 01_critical.rb will be loaded before 02_normal.rb.

檔名加個數字前綴,rails 就會以數字順序來依序載入~


Back to posts


comments powered by Disqus