Search code examples
rubymongodbruby-on-rails-3pumapuma-dev

How can I found out were my ROR app is getting its ENV variables


I took over a ROR app and I have changed ENV vars in local_env.yml and in .env to point to a new MongoDB server on MongoDB Atlas and away from MLab.However, the app is still hitting the db on MLab.

So I also did the following:

  1. I checked the computer and there were the same ENV in bash_profile, which I have changed.
  2. I then did a source ~/.bash_profile
  3. I restarted Puma but the app is still using Mlab DB which is reached via ENV[MONGO].

Is there a way to find out where the app is pulling the ENV variables from?


Solution

  • There is nothing specific in ruby to find out where environment variables are set because they are ENVIRONMENT VARIABLES so first understand what that means.

    You could try to grep recursive

    grep -rnw 'base/path/to/search/' -e 'MONGO'
    

    There may be other ways to hunt them down depending on what shell you use. But if they are loaded from a file that is not loaded by the shell, but by your ruby app i.e. a yaml file , these may not help you. For more info see this answer