问题描述
所以,我正在使用存储我的秘密twitter和Facebook oauth键,所以我可以正确部署到Heroku我只想确认我做的正确。
So, I'm using Figaro to store my secret twitter, and Facebook oauth keys so I can deploy to Heroku properly. I'd just like to confirm that I am doing it right.
在我的application.yml(由figaro生成):
In my application.yml (generated by figaro):
// Add application configuration variables here, as shown below.
//
// PUSHER_APP_ID: "2954"
// PUSHER_KEY: 7381a978f7dd7f9a1117
// PUSHER_SECRET: abdc3b896a0ffb85d373
// STRIPE_API_KEY: EdAvEPVEC3LuaTg5Q3z6WbDVqZlcBQ8Z
// STRIPE_PUBLIC_KEY: pk_BRgD57O8fHja9HxduJUszhef6jCyS
// note these are arbitrary keys for the stack overflow
FR_FACEBOOK_KEY=1231231233123123
FR_FACEBOOK_SECRET=3123123123123
TWITTER_CONSUMER_KEY=12312312312312
TWITTER_CONSUMER_SECRET=1312312312312
所以这是application.yml,那么我只需要运行:
So that's the application.yml, then I simply need to run:
heroku config:add FR_FACEBOOK_KEY=8926 // and so on...
正确吗?
还是我缺少某些东西?
感谢高级!
当我运行rake figaro:heroku我得到这个错误:
When I run rake figaro:heroku I'm getting this error:
[new_work]$rake figaro:heroku
rake aborted!
undefined method `reject' for #<String:0x007fbdc6c0e2a8>
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/figaro-0.7.0/lib/figaro.rb:39:in `flatten'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/figaro-0.7.0/lib/figaro.rb:17:in `env'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/figaro-0.7.0/lib/figaro/railtie.rb:7:in `block in <class:Railtie>'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0.rc1/lib/active_support/lazy_load_hooks.rb:36:in `call'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0.rc1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0.rc1/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0.rc1/lib/active_support/lazy_load_hooks.rb:44:in `each'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0.rc1/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0.rc1/lib/rails/application.rb:67:in `inherited'
/Users/usr/Sites/new_work/config/application.rb:22:in `<module:Friendiose>'
/Users/usr/Sites/new_work/config/application.rb:21:in `<top (required)>'
/Users/usr/Sites/new_work/Rakefile:5:in `require'
/Users/usr/Sites/new_work/Rakefile:5:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)
推荐答案
记住使用:
而不是 =
来分隔你的键和值。您可以使用 ENV [KEY_NAME]
Remember to use :
instead of =
to separate your keys and values. You can access the keys from your rails app using ENV["KEY_NAME"]
从您的rails应用程序访问密钥。但是,您没有到$ code> heroku config:添加键,而你有费加罗,只需使用 rake figaro:heroku
如这里所述
However, you do not have to heroku config:add
keys while you have Figaro, just use rake figaro:heroku
as explained here https://github.com/laserlemon/figaro
这篇关于这些figaro配置设置是否适用于heroku部署?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!