I’ve been trying to figure out how Ryan Bates, in his Facebook Authentication screencast, is setting the following “FACEBOOK_APP_ID” and “FACEBOOK_SECRET” environment variables.
provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_SECRET']
There are similar-ish questions around, but no answers that I’ve been able to get to work on Rails 3.2.1.
UPDATE:
As of May 2013, my preferred way to handle ENV variables is via the Figaro gem
You could take a look at the comments:
You can either set environment variables directly on the shell where you are starting your server:
Or (rather hacky), you could set them in your
config/environments/development.rb:An alternative way
However I would do neither. I would create a config file (say
config/facebook.yml) which holds the corresponding values for every environment. And then load this as a constant in an initializer:config/facebook.ymlconfig/initializers/facebook.rbThen replace
ENV['FACEBOOK_APP_ID']in your code byFACEBOOK_CONFIG['app_id']andENV['FACEBOOK_SECRET']byFACEBOOK_CONFIG['secret'].