没有Rails的IRB控制台中的Figaro?

问题描述 投票:0回答:1

环境:Ubuntu 18.04 Ruby 2.5.1私有宝石

遵循的步骤:

  • Gemfile中的gem 'figaro'
  • bundle install =>创建了config.yml
  • 取消注释演示变量以测试驱动器费加罗
  • bin / console中的require 'figaro'
  • 来自命令行的bin/console

我无法访问figaro中的变量。有没有办法在不使用Rails的情况下使用figaro?

演示变量:

# Add configuration values here, as shown below.
#
pusher_app_id: "2954"
pusher_key: 7381a978f7dd7f9a1117
pusher_secret: abdc3b896a0ffb85d373
stripe_api_key: sk_test_2J0l093xOyW72XUYJHE4Dv2r
stripe_publishable_key: pk_test_ro9jV5SNwGb1yYlQfzG17LHK

production:
  stripe_api_key: sk_live_EeHnL644i6zo4Iyq4v1KdV9H
  stripe_publishable_key: pk_live_9lcthxpSIHbGwmdO941O1XVU
ruby rubygems environment-variables
1个回答
0
投票

您可以在rails控制台中访问下面的那些演示变量

ENV['pusher_app_id'] #=> '2954'
ENV['pusher_key'] #=>  '7381a978f7dd7f9a1117'

通过使用Figaro.env,您可以通过以下方式访问:

Figaro.env.pusher_app_id #=> '2954'
Figaro.env.pusher_key #=>  '7381a978f7dd7f9a1117'
© www.soinside.com 2019 - 2024. All rights reserved.