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.

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

22 Mar 11:24

What is CI/CD in software development?

meme code
meme code@memecode
What is DDL (Data Definition Language) and DML (Data Manipulation Language)? When and for what purposes are they used?
27 Mar 18:37

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

meme code
meme code@memecode
27 Mar 18:47

What is an atomic transaction?

meme code
meme code@memecode
What are TCL (Transaction Control Language), DCL (Data Control Language), and DQL (Data Query Language)
27 Mar 19:04

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

meme code
meme code@memecode
02 Apr 07:17

What is Concurrency in IT?

meme code
meme code@memecode
03 Apr 06:17

What is process management in software development?

meme code
meme code@memecode
03 Apr 06:49

What is SSR (Server Side Rendering)?

meme code
meme code@memecode
03 Apr 06:53

What is CSR (Client Side Rendering)?

meme code
meme code@memecode
10 Apr 07:46

What is a Webserver and an Application Server?

meme code
meme code@memecode
10 Apr 07:58

What is a Packet in IT?

meme code
meme code@memecode
12 Apr 09:17

What is the HTTP Connect method used for?

meme code
meme code@memecode
12 Apr 09:24

What is the purpose of the HTTP DELETE method?

meme code
meme code@memecode