环境:Ubuntu 18.04 Ruby 2.5.1私有宝石
遵循的步骤:
gem 'figaro'
bundle install
=>创建了config.ymlrequire '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
您可以在rails控制台中访问下面的那些演示变量
ENV['pusher_app_id'] #=> '2954'
ENV['pusher_key'] #=> '7381a978f7dd7f9a1117'
通过使用Figaro.env,您可以通过以下方式访问:
Figaro.env.pusher_app_id #=> '2954'
Figaro.env.pusher_key #=> '7381a978f7dd7f9a1117'