Setting Environment Variables in Rails 3 (Devise + Omniauth)

后端 未结 3 1547
鱼传尺愫
鱼传尺愫 2020-11-29 16:52

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

3条回答
  •  广开言路
    2020-11-29 17:12

    Here's another idea. Define the keys and values in provider.yml file, as suggested above. Then put this in your environment.rb (before the call to Application.initialize!):

    YAML.load_file("#{::Rails.root}/config/provider.yml")[::Rails.env].each {|k,v| ENV[k] = v }
    

    Then these environment variables can be referenced in the omniauth initializer without any ordering dependency among intializers.

提交回复
热议问题