SwitchUp SwitchUp Ranked Best Coding Bootcamps 2025

Environments

Written in Ruby on Rails
updated on 10 Jan 2023

In Rails, there are three main environments: development, test and production. Essentially, environments are segregated boxes where your actions in one box don't affect other boxes. This allows you to do whatever you want in one environment without worrying about messing up another environment.

Development

When you are coding or developing on your local machine (the computer in front of you), you are typically in the development environment – the environment for development.

Test

As you have discovered, any code you modify may affect other codes in your code base. You don't want to accidentally break your program when you only change 1 line of code. The solution is to constantly test your program to make sure nothing breaks. If you happens to have a huge code base, it will take a long time to test the entire program. The solution is to write codes with the purpose of testing your main code – known as tests. Tests usually run in the test environment.

Production

The production environment is the one where your code is used by real people and/or paying customers. It's important that you make sure your production environment is always up and running.

Notes for Rails Migrations
When you are running migrations or rollbacks, Rails will typically run them in both the development and test environment. However, there are cases when it only runs in one environment. Make sure you check this when you are running into related problems.

To specify running an action in certain environment, add RAILS_ENV=<name of the environment> to your command. For example, $ rails db:rollback RAILS_ENV=test.

Trusted by

Students and instructors from world-class organizations

Join the upcoming Cohort #120

Enroll for December 7th, 2026