rails中设置配置信息 读取配置信息

安装gem包

gem 'figaro'

执行bundle install figaro install 会发现多了一个application.yml文件.在.gitgnore中多了一行

在application.yml中添加配置信息

pusher_app_id: "2954"
pusher_key: 7381a978f7dd7f9a1117
pusher_secret: abdc3b896a0ffb85d373
stripe_api_key: sk_test_2J0l093xOyW72XUYJHE4Dv2r
stripe_publishable_key: pk_test_ro9jV5SNwGb1yYlQfzG17LHK

在程序中读取配置信息

pusher_app_id=Figaro.env.pusher_app_id
原文地址:https://www.cnblogs.com/dccmmtop/p/7514278.html