我曾在〜/ .bashrc保存一些ENV
的,请重新打开该文件,我可以有看到他们:然而如何让我的Rails应用程序使用我的〜/ .bashrc保存的ENV VARS?
export SECRET_KEY_BASE="secretkeyhere"
export S3_SECRET_KEY="anotherhere"
export S3_ACCESS_KEY="andhere"
export DEVISE_KEY="and again"
,当我告诉我的Rails应用程序使用它们,例如S3凭据在我与ENV["S3_ACCESS_KEY"]
模型它似乎没有使用它们,给我的错误:
Missing Credentials. Unable to find AWS credentials. You can configure your AWS credentials a few different ways: * Call AWS.config with :access_key_id and :secret_access_key * Export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to ENV * On EC2 you can run instances with an IAM instance profile and credentials will be auto loaded from the instance metadata service on those instances. * Call AWS.config with :credential_provider. A credential provider should either include AWS::Core::CredentialProviders::Provider or respond to the same public methods. = Ruby on Rails In a Ruby on Rails application you may also specify your credentials in the following ways: * Via a config initializer script using any of the methods mentioned above (e.g. RAILS_ROOT/config/initializers/aws-sdk.rb). * Via a yaml configuration file located at RAILS_ROOT/config/aws.yml. This file should be formated like the default RAILS_ROOT/config/database.yml file.
当壳我运行echo $DEVISE_KEY
并返回不过是一个空行,如果我跑source ~/.bashrc
然后echo $DEVISE_KEY
它返回键?!?因此,它似乎在某处,但不能通过rails和/或正确的会话/环境/程序访问。作为UNIX的初级,Rails以及更多,我现在对这里发生的事情感到不知所措。请你能帮我理解我在这里做错了什么。谢谢。
您是否尝试过采购您的bashrc文件? – Joel 2015-02-09 22:33:15
我试着在bash窗口中运行'source〜/ .bashrc',然后'echo $ DEVISE_KEY'会返回密钥。然而,Rails仍然在PostsController#create'错误中返回相同的'AWS :: Errors :: MissingCredentialsError? – jbk 2015-02-10 11:05:50