confusing about autoload_paths vs eager_load_paths in rails 4

后端 未结 2 1731
孤街浪徒
孤街浪徒 2020-11-29 17:10

I read a post about the rails load_paths, here is the link.

But, I am still confused about the difference between the autoload_paths and eager_loa

2条回答
  •  独厮守ぢ
    2020-11-29 17:42

    Basically, autoload_paths are paths Rails will use to try loading your classes automatically. E.g. when you call Book, if that class isn't loaded yet, it will go through the autoload_paths and look for it in those paths.

    In production, it might be better to load those upfront to avoid autoload concurrent issues. For that, it provides the eager_load_paths. Paths in that list will be required upfront when your application starts.

提交回复
热议问题