How to set and describe environment variables using Rails zsh

While using the Google Map API, I just wrote the API I got and pushed it on Git Hub. Then I got this email from Git Hub ... GitGuardian has detected the following Google Key exposed within your GitHub account. ** GitGuardian has detected the following Google keys published within your GitHub account: ** ** Great! I was impressed that GitHub can do such a thing. I'm not impressed, so I immediately put it in an environment variable and tried to change the description, so please share it

What are environment variables

I think it's okay to have an image such as a variable that hides things you don't want to show.

And there are many things you can set environment variables for, so try to find a good one for yourself! In my case, I use ** zsh ** to set environment variables.

zsh seems to be the self-proclaimed "strongest" shell

How to install Zsh

For beginners: Introduction of Zsh This article was very easy to understand! Please install Zsh from this article

How to set environment variables using Zsh

% vim ~/.zshrc

Open .zsher in Then スクリーンショット 2020-10-17 12.13.25.png I think the screen looks like this Since I have already set various settings, there are many contents described, but please ignore it ** When this screen opens, please enter "i" for the time being ** At the bottom left

-- INSERT--

This is called ** insert mode ** Because you will be able to input

export Variable name you want to use='Value you want to hide' #Please be careful not to put a space in the equal

Example

export GOOGLE_MAP_API='hoge'

If you write like this, the setting is completed

The command to exit insert mode is ** esc key ** exit After exiting ** ": wq" ** when saving settings ** ": q!" ** when not saving Please end with

afterwards Reload .zshrc and enable defined environment variables

source ~/.zshrc

This completes the environment variable settings.

How to use the set environment variables

Basically

ENV['Environment variables set']

And use When writing API KEY in view by using API

<%= ENV['Environment variables installed'] %>

Write That's it!

Recommended Posts

How to set and describe environment variables using Rails zsh
How to set environment variables when using Payjp with Rails
[Rails] How to upload images to AWS S3 using Carrierwave and fog-aws
[Rails] How to upload images to AWS S3 using refile and refile-s3
[Rails] How to upload images using Carrierwave
How to set up and use kapt
How to use environment variables in RubyOnRails
How to implement image posting using rails
[Rails] How to handle data using enum
How to build Rails 6 environment with Docker
How to create a query using variables in GraphQL [Using Ruby on Rails]
How to build a Ruby on Rails environment using Docker (for Docker beginners)
[Docker] How to create a virtual environment for Rails and Nuxt.js apps
[Node.js express Docker] How to define Docker environment variables and load them with node.js
How to apply Rails environment variables to Docker container (aws :: Sigv4 :: Errors solution)
How to output Excel and PDF using Excella
How to execute and mock methods using JUnit
[Rails] How to create a graph using lazy_high_charts
(Basic authentication) environment variables in rails and Docker
How to play audio and music using javascript
How to set up and operate jEnv (Mac)
[Rails] How to upload multiple images using Carrierwave
Rails6.0 ~ How to create an eco-friendly development environment
How to build API with GraphQL and Rails
[Rails] How to build an environment with Docker
[Rails] How to get success and error messages
Introduce dotenv to Docker + Rails to manage environment variables
[Rails] How to use PostgreSQL in Vagrant environment
Rails scope anti-patterns and how to eliminate them
How to set environment variables in the properties file of Spring boot application
How to write Rails
How to uninstall Rails
How to set the display time to Japan time in Rails
How to convert A to a and a to A using AND and OR in Java
[Rails 6] How to set a background image in Rails [CSS]
[Rails] How to edit and customize devise view and controller
[Rails] Create sitemap using sitemap_generator and deploy to GAE
Rails learning How to implement search function using ActiveModel
(Ruby on Rails6) How to create models and tables
[Rails] How to install a decorator using gem draper
Try to implement tagging function using rails and js
[Rails] [Docker] Copy and paste is OK! How to build a Rails development environment with Docker
[Rough explanation] How to separate the operation of the production environment and the development environment with Rails
How to implement a circular profile image in Rails using CarrierWave and R Magick
[Rails / Routing] Deepen on how to set Prefix and URI to your favorite values and resources
How to test including images when using ActiveStorage and Faker
[rails] How to post images
How to separate words in names in classes, methods, and variables
[Rails] How to use enum
[Rails] How to install devise
[Rails] How to use enum
How to read rails routes
[Rails] How to define macros in Rspec and standardize processing
Prevent operations! How to securely update Rails manually using transactions
[Rails] Differences between redirect_to and render methods and how to output render methods
[Environment variables] What are rails environment variables?
How to set Docker nginx
How to use rails join
How to deploy jQuery in your Rails app using Webpacker
How to set Java constants
[Rails] How to delete images uploaded by carrierwave (using devise)