How do I see the ENV vars in a Rails app?

Assuming the staging environment, as your example points to. You’ll want to load the console by prepending the RAILS_ENV environment variable to the rails console command.

RAILS_ENV=staging rails console

That should get you in. Once you’re in, you can just access the ENV variable directly.

2.2.2 (main):0 > ENV

And that will dump out the environment variables for you. Note, your prompt may look different. If you want to access a specific value, such as the database password, you can:

2.2.2 (main):0 > ENV['STAGE_DATABASE_PASSWORD']

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)