Web Development

It is always a better idea for configuration variables to stay on the server as environment variables instead of putting them on your repository. It makes it less likely for someone to have access to them. Here are a few ways to set environment variables for your Rails application.

~/.bashrc File

This is the simplest and most obvious of the 3. It is default way you are going to do it. Just add the environment variables in your ~/.bashrc file.

export APPLICATION="Application Name"
export APPLICATION_VERSION="Application Version"


dotenv is a Ruby gem to load environment variables from an env file.


gem 'dotenv-rails', groups: [:development, :test]

And then execute:

$ bundle


Figaro is a nice gem that simplifies configuration files.

gem "figaro"

You might need to add the additional yml file to .gitignore.

# config/application.yml

application_conf: "882354"
application_key: "fausdhf7(0sadfsmd__nfasdf"
some_conf: "23456789hdsfdsfasdf132"

These can be used throughout the application via ENV["application_key"]