I recommend using https://github.com/bkeepers/dotenv gem if you want to load .env file with ENV variables.
(如果您要使用ENV变量加载.env文件,建议使用https://github.com/bkeepers/dotenv gem。)
If you are already using it then according to dotenv readme you should load as soon as possible on boot, for example in config/application.rb add: (如果您已经在使用它,那么根据dotenv自述文件,您应该在引导时尽快加载,例如在config / application.rb中添加:)
require 'dotenv'
Dotenv.load
If you use PUMA or Unicorn, in config/puma.rb, config/unicorn.rb add:
(如果使用PUMA或Unicorn,请在config / puma.rb中的config / unicorn.rb中添加:)
require "dotenv"
Dotenv.load("/path/to/env/.env")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…