因此,我正在使用Figaro存储我的秘密Twitter和Facebook oauth密钥,以便可以正确地部署到Heroku。我只想确认我做对了。
在我的application.yml(由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,然后我只需要运行:
heroku config:add FR_FACEBOOK_KEY=8926 // and so on...
正确?
还是我错过了什么?
提前致谢!
当我运行rake figaro:heroku时,出现此错误:
[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"]
从rails应用访问密钥。
但是,在使用Figaro时,您不必按heroku config:add
键,只需使用rake figaro:heroku
,如此处https://github.com/laserlemon/figaro所述