Spring is a Rails application preloader. It speeds up development by keeping your application running in the background, so you don't need to boot it

Search code, repositories, users, issues, pull requests...

submited by
Style Pass
2024-04-25 11:30:07

Spring is a Rails application preloader. It speeds up development by keeping your application running in the background, so you don't need to boot it every time you run a test, rake task or migration.

Spring makes extensive use of Process.fork, so won't be able to provide a speed up on platforms which don't support forking (Windows, JRuby).

This generates a bin/spring executable, and inserts a small snippet of code into relevant existing executables. The snippet looks like this:

On platforms where Spring is installed and supported, this snippet hooks Spring into the execution of commands. In other cases, the snippet will just be silently ignored, and the lines after it will be executed as normal.

If you don't want to prefix every command you type with bin/, you can use direnv to automatically add ./bin to your PATH when you cd into your application. Simply create an .envrc file with the command PATH_add bin in your Rails directory.

Ensure that config.enable_reloading is true in the environments that Spring manages. That setting is typically configured in config/environments/*.rb. In particular, make sure it is true for the test environment.

Leave a Comment