Intern Track Roadmap

Environment: dev vs test

This course explains what Rails means by environment: one of three named modes (development, test and production) tracked by Rails.env and set through the RAILS_ENV variable. It keeps that idea apart from a computer's own setup of editor, Ruby version and PostgreSQL. The lessons read development.rb, test.rb and production.rb line by line, covering code reloading, eager loading, error pages, HTTPS and allowed hosts. They also show how database.yml sends each environment to its own databases, and how -e test and --sandbox combine in the console.

What you'll learn

  • ✓How Rails.env and the RAILS_ENV variable pick one of three modes
  • ✓Line-by-line differences between development.rb and test.rb
  • ✓What production.rb changes: eager loading, error pages, HTTPS and allowed hosts
  • ✓How database.yml gives each environment its own databases and connections
  • ✓Switching environments with RAILS_ENV or bin/rails console -e test
  • ✓How -e and --sandbox answer different questions in a console session
Free preview · Lesson 1 2 min read

Two kinds of environment

The Rails CLI: rails new course's config lesson named three files in passing: "config/environments/development.rb, test.rb and production.rb each override application.rb for one environment." Then it added: "Environment: dev vs test covers this split later." This is that course.

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...