Rails environments reflect the stages of development for a typical application: development, test, and production.
You can set the Rails environment by doing one or both of the following:
Set the RAILS_ENV environment variable to the environment name (development, test, or production).
Modify config/environment.rb and update the line (be sure that it is not commented out):
ENV['RAILS_ENV'] ||= 'production'
Within the Rails application, the environment name can be accessed with:
The three default Rails environments are:
The development environment is used primarily when developing Rails applications. The application’s code is reloaded on every request, which slows down the response time but is ideal, as the developer does not have to restart the server when changes are made.
The test environment is used exclusively to run your application’s test suite. You should never need to work with it otherwise. Remember that your test database is scratch space for the test suite and is wiped and recreated between test runs. Don’t rely on the data there!
The production environment is meant for finished, “live” apps. Code is not reloaded between requests, but the response time is much faster than that of the development mode.
1.5.1. Configuring Your Environment
Three environment files—development.rb, test.rb, and production.rb—are generated in the config/environments folder when the Rails application is created. Each contains configuration settings for ...