Last Updated: February 25, 2016
·
465
· dpaluy

Managing multiple environments with Heroku

If you want to manage production and staging environments in Heroku you can follow this guide

But if you have another local server for QA that no hosted in Heroku, and you have specific group of gems for it, you can avoid installing those gems in production/staging by adding the following code, in your Gemfile:

# Heroku Patch
def hg(g)
  (ENV['HOME'].gsub('/','') == 'app' ? 'test' : g)
end

group hg(:qa) do
  gem 'sqlite3'
end

Note: if your ENV['HOME']is not always defined, you probably should add some patch to avoid exceptions. For example:

ENV['HOME'] = '/home/anyuser' if ENV['HOME'].nil? #patch