尝试将S3集成到我的回形针课程中。 在我的当地人和同事那里取得了如此成功,但它并没有从事生产。
这是我的图片类的回形针代码:
has_attached_file :image,
storage: :s3,
:path => ":imageable_type/:imageable_id/:filename",
s3_credentials: {
access_key_id: ENV["AWS_KEY"],
secret_access_key: ENV["AWS_SECRET"],
bucket: ENV["S3_BUCKET"]
},
s3_region: ENV["S3_REGION"]
我收到以下错误NoMethodError (undefined method 'match' for nil:NilClass):
。快速搜索显示它与未提及的s3_region
相关。
它适用于我的开发服务器,s3_region
包含在我的配置中。
我已经定义了插值和环境变量。环境变量在rails控制台中工作,因此我认为这不是问题。
任何帮助将不胜感激
答案 0 :(得分:0)
您使用什么部署到生产?
例如,如果您使用Heroku,则需要单独保留生产服务器中的env
变量。您可以通过仪表板或终端
What are the other heroku environment variables?
https://devcenter.heroku.com/articles/config-vars
如果您使用AWS,请阅读此处
http://docs.aws.amazon.com/lambda/latest/dg/env_variables.html
对于码头工人,请阅读
https://docs.docker.com/compose/link-env-deprecated/
env变量在您正在运行的每个ubuntu服务器/容器的~/.bash_profile
或~/.bashrc
等文件中定义
详细了解环境变量以及如何配置它们