I have an initializer file that looks like this:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, '000000000000000', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
end
And my app works.
I don't want to hardcode credentials so I changed it to:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET']
end
I set the corresponding environment variables in bash, and restarted my app.
When I use the rails console, ENV['FACEBOOK_KEY'] and ENV['FACEBOOK_SECRET'] output the correct values.
But my app does not work anymore, I get a response with "Missing client_id parameter" when using omniauth.
{
"error": {
"message": "Missing client_id parameter.",
"type": "OAuthException"
}
}
I'm confused.
Isn't it the correct way to access environment variables ? Does it work another way in initializers ?
How can I access the environment variables from the initializer ?
BTW I'm using Ubuntu 11.04.
Thanks