Setting Environment Variables in Rails 3 (Devise + Omniauth)

后端 未结 3 1546
鱼传尺愫
鱼传尺愫 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:00

    There are several options:

    • Set the environment variables from the command line:

      export FACEBOOK_APP_ID=your_app_id
      export FACEBOOK_SECRET=your_secret
      

      You can put the above lines in your ~/.bashrc

    • Set the environment variables when running rails s:

      FACEBOOK_APP_ID=your_app_id FACEBOOK_SECRET=your_secret rails s
      
    • Create a .env file with:

      FACEBOOK_APP_ID=your_app_id
      FACEBOOK_SECRET=your_secret
      

      and use either Foreman (starting your app with foreman start) or the dotenv gem.

提交回复
热议问题