All original content is created in Ukrainian. Not all content has been translated yet. Some posts may only be available in Ukrainian.Learn more

What are Environment Variables in software development?

Post cover: What are Environment Variables in software development?
This content has been automatically translated from Ukrainian.
Environment Variables (Environment Variables) are configuration settings that are stored at the operating system level (for example, used by Ruby on Rails applications during runtime). They allow you to manage sensitive (confidential) information, such as database credentials or API keys, as well as configure the behavior of the application in different deployment environments, such as development, testing, and production.

What types of information can be stored in Environment Variables?

Environment Variables can store a variety of information, including database connection data, API keys, secret tokens, local development environment settings, and more.

How to access Environment Variables in a Ruby on Rails application?

In Ruby on Rails applications, access to Environment Variables can be obtained using the special object ENV, which provides access to all environment variables stored in the operating system.

Example of using Environment Variables

Imagine we have an application that uses an API key to interact with a third-party service. Instead of hardcoding the API key directly in the code, we can store it as an Environment Variable.
For example:
# Code in Ruby on Rails application to get the API key from Environment Variable
api_key = ENV['API_KEY']
Thus, we can store confidential information, such as API keys, in Environment Variables, making our application more secure and flexible in different deployment environments.
The main rule is not to commit keys to a Git repository. Use Env variables instead.
Like it?React
🧵

This post doesn't have any additions from the author yet.

Apr 3, '24 06:17

What is process management in software development?

Mar 22, '24 11:24

What is CI/CD in software development?

What is the difference between spec_helper.rb and rails_helper.rb in RSpec?
Dec 8, '24 13:53

What is the difference between spec_helper.rb and rails_helper.rb in RSpec?

Main methods of authentication in API
Oct 19, '25 20:26

Main methods of authentication in API

May 24, '23 18:53

What are joins in Ruby on Rails and how does it work?

Apr 3, '24 06:49

What is SSR (Server Side Rendering)?

Apr 3, '24 06:53

What is CSR (Client Side Rendering)?

Apr 2, '24 07:17

What is Concurrency in IT?

What are TCL (Transaction Control Language), DCL (Data Control Language), and DQL (Data Query Language)
Mar 27, '24 19:04

What are TCL (Transaction Control Language), DCL (Data Control Language), and DQL (Data Query Language)

Mar 27, '24 18:47

What is an atomic transaction?

What is DDL (Data Definition Language) and DML (Data Manipulation Language)? When and for what purposes are they used?
Mar 27, '24 18:37

What is DDL (Data Definition Language) and DML (Data Manipulation Language)? When and for what purposes are they used?

Apr 10, '24 07:46

What is a Webserver and an Application Server?

Apr 10, '24 07:58

What is a Packet in IT?

Apr 12, '24 09:17

What is the HTTP Connect method used for?

Apr 12, '24 09:24

What is the purpose of the HTTP DELETE method?