我正在关注Daniel Keogh的学习导航教程,并完全坚持设置密钥。我在.bashrc文件中设置了以下内容:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export GMAIL_USERNAME="entered my gmail here"
export GMAIL_PASSWORD="and pass here"
export MAILCHIMP_API_KEY="key here"
export MAILCHIMP_LIST_ID="id here"
export OWNER_EMAIL="as per above"
export SECRET_KEY_BASE="754735714c2b591df6fedeeba6b6d0a118ce6d9cb01382022f01d2f1be5ac97143204c9726d37ab44b516542ed49a0a17e671b5b9b9100dd902140c164695859"
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"`enter code here`
然后我设置了我的秘密文件:
development:
email_provider_username: <%= ENV["GMAIL_USERNAME"] %>
email_provider_password: <%= ENV["GMAIL_PASSWORD"] %>
mailchimp_api_key: <%= ENV["MAILCHIMP_API_KEY"] %>
mailchimp_list_id: <%= ENV["MAILCHIMP_LIST_ID"] %>
domain_name: example.com
owner_email: <%= ENV["OWNER_EMAIL"] %>
secret_key_base: 754735714c2b591df6fedeeba6b6d0a118ce6d9cb01382022f01d2f1be5ac97143204c9726d37ab44b516542ed49a0a17e671b5b9b9100dd902140c164695859
test:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
email_provider_username: <%= ENV["GMAIL_USERNAME"] %>
email_provider_password: <%= ENV["GMAIL_PASSWORD"] %>
mailchimp_api_key: <%= ENV["MAILCHIMP_API_KEY"] %>
mailchimp_list_id: <%= ENV["MAILCHIMP_LIST_ID"] %>
domain_name: <%= ENV["DOMAIN_NAME"] %>
owner_email: <%= ENV["OWNER_EMAIL"] %>
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
当我启动Web服务器时,我得到了这个:
内部服务器错误
缺少secret_key_base
'开发'环境,请在config/secrets.yml
中设置此值
WEBrick / 1.3.1(Ruby / 2.1.1 / 2014-02-24)0.0.0.0:3000
在网上找不到任何答案,现在已经坚持了好几天!我究竟做错了什么?
答案 0 :(得分:1)
我遇到了同样的问题,我也在ZSH下运行我的ENV。我需要将书中的信息包含在两个地方。
的.bash_profile
.zshrc
我在这两个位置使用了相同的导入使用硬编码变量 (已删除个人资料以供回答)
export SECRET_KEY_BASE="*********************"
export GMAIL_USERNAME="**************"
export GMAIL_PASSWORD="**********"
export MAILCHIMP_API_KEY="***********-us9"
export MAILCHIMP_LIST_ID="***********"
export OWNER_EMAIL="****@example.com"
然后我使用以下方法设置secrets.yml文件:
development:
email_provider_username: <%= ENV["GMAIL_USERNAME"] %>
email_provider_password: <%= ENV["GMAIL_PASSWORD"] %>
mailchimp_api_key: <%= ENV["MAILCHIMP_API_KEY"] %>
mailchimp_list_id: <%= ENV["MAILCHIMP_LIST_ID"] %>
domain_name: example.com
owner_email: <%= ENV["OWNER_EMAIL"] %>
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
关闭终端并重新启动终端,重新启动服务器,然后我就可以提交到Google云端硬盘
答案 1 :(得分:0)
你的缩进应该是
development:
email_provider_username: <%= ENV["GMAIL_USERNAME"] %>
email_provider_password: <%= ENV["GMAIL_PASSWORD"] %>
mailchimp_api_key: <%= ENV["MAILCHIMP_API_KEY"] %>
mailchimp_list_id: <%= ENV["MAILCHIMP_LIST_ID"] %>
domain_name: example.com
owner_email: <%= ENV["OWNER_EMAIL"] %>
secret_key_base: 754735714c2b591df6fedeeba6b6d0a118ce6d9cb01382022f01d2f1be5ac97143204c9726d37ab44b516542ed49a0a17e671b5b9b9100dd902140c164695859
test:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
email_provider_username: <%= ENV["GMAIL_USERNAME"] %>
email_provider_password: <%= ENV["GMAIL_PASSWORD"] %>
mailchimp_api_key: <%= ENV["MAILCHIMP_API_KEY"] %>
mailchimp_list_id: <%= ENV["MAILCHIMP_LIST_ID"] %>
domain_name: <%= ENV["DOMAIN_NAME"] %>
owner_email: <%= ENV["OWNER_EMAIL"] %>
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>