Rails autoload and eager_load

11 Jul 2020

Rails constants load:

  • Do eager_load in production
  • Do autoload in development

autoload will still happens during the eager_load porcess autoload will be closed after eager_load finish in production

Development requirements

  • quick startup
  • load file as need
  • reload file when they chang

So autoload mode suit for that

Production requirements

  • Consistency
  • Thread-safety
  • Long boot time is ok

So eager_load suit for that. Load all files in eager_load_paths during boot, then turn of autoload.

Back to top