1

I have installed a rails app using the rails composer. I selected .env with foreman. In my .env file I have:

OMNIAUTH_PROVIDER_KEY=key

and I am trying to get its value.

But, when I ran ENV["OMNIAUTH_PROVIDER_KEY"] I got nil. What am I doing wrong?

K M Rakibul Islam
  • 33,760
  • 12
  • 89
  • 110
Raaz
  • 1,669
  • 2
  • 24
  • 48
  • Have you restart your server after adding variable in .env file? – Salil Oct 28 '15 at 05:10
  • @Salil, yes and still no luck. In rails console , i ran ENV["OMNIAUTH_PROVIDER_KEY"] and it outpus nil – Raaz Oct 28 '15 at 05:11
  • Have you restart your console? – user2322409 Oct 28 '15 at 05:29
  • @user2322409, yes I have. Is it because I used rails composer? – Raaz Oct 28 '15 at 05:35
  • @RajShakya what do you mean you "ran" `ENV["OMNIAUTH_PROVIDER_KEY"]`? Give us the location and code that you used to check it. – neanderslob Oct 28 '15 at 06:06
  • in my secrets.yml file , i have this code `omniauth_provider_key: <%= ENV["OMNIAUTH_PROVIDER_KEY"] %>` but when I ran my app I got errors because the key was not found. So I tried ENV["OMNIAUTH_PROVIDER_KEY"].inspect in the view but it showed me nil and again I ran it in rails console and again got nil. I am unable to get the value from .env file. @neanderslob – Raaz Oct 28 '15 at 06:28
  • @RajShakya beats me man. Good luck! – neanderslob Oct 28 '15 at 06:53

1 Answers1

2

Add the dotenv gem to your gemfile:

https://github.com/bkeepers/dotenv

aguynamedloren
  • 2,273
  • 18
  • 23