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.

Mar 22, '24 11:24

What is CI/CD in software development?

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?

Mar 27, '24 18:47

What is an atomic transaction?

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)

Apr 2, '24 07:17

What is Concurrency in IT?

Apr 3, '24 06:17

What is process management in software development?

Apr 3, '24 06:49

What is SSR (Server Side Rendering)?

Apr 3, '24 06:53

What is CSR (Client Side Rendering)?

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?