回形针缺少必要的

回形针缺少必要的

本文介绍了AWS S3,回形针缺少必要的:斗选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用回形针和SWS S3在Heroku上,让用户上传照片。

I'm trying to use Paperclip and SWS S3 on Heroku to let users upload images.

我没有保存在一个文件阳明海运我的凭据。我已经试过了Heroku的页面上的说明:https://devcenter.heroku.com/articles/paperclip-s3

I do not have my credentials stored in a yml file. I've followed the instructions on the Heroku page:https://devcenter.heroku.com/articles/paperclip-s3

但是,当我尝试运行我的应用程序,并上传一张图片,我得到这个消息:

But, when I try to run my app and upload an image I'm getting this message:

missing required :bucket option
Rails.root: /Users/scottsipiora/Sites/clycss

Application Trace | Framework Trace | Full Trace
app/controllers/instructors_controller.rb:63:in `block in update'
app/controllers/instructors_controller.rb:62:in `update'

的说明没有提到关于制造变化在我的控制器东西。我见过一些例子告诉我放在这样的:

The instructions don't mention anything about making a change in my controller. I have seen some examples telling me to put in something like:

在我的模型,我有以下code:

In my model I have the following code:

class Instructor < ActiveRecord::Base
  attr_accessible :bio, :hometown, :name, :school, :sort_order, :started_sailing, :started_teaching, :photo
  has_attached_file :photo, styles: {
    thumb: '100x100>',
    square: '200x200#',
    medium: '300x300>'
  }
end

在我production.rb我已(很明显,模拟凭证代替我的真实凭证):

In my production.rb I have (obviously replacing my real credentials with mock credentials):

  config.paperclip_defaults = {
    :storage => :s3,
    :s3_credentials => {
      :bucket => ENV['bucket name'],
      :access_key_id => ENV['key_id'],
      :secret_access_key => ENV['access_key']
    }
  }

我也创造了生产和开发独立的桶这样的事情是清洁。

I've also created separate buckets for Production and Dev so things are cleaner.

任何想法?我是比较新的,这应该是pretty的方便。

Any ideas? I'm relatively new and this should be pretty easy.

在此先感谢。

推荐答案

我想你可能已经犯了同样的错误,我做到了。在您的production.rb文件,不修改添加特定的S3键文本。只需直接复制粘贴作为被列入教程的文字。

I think you may have made the same mistake I did. In your production.rb file, do not edit the text to add your specific S3 keys. Just copy-paste the text directly as is listed in the tutorial.

#production.rb
config.paperclip_defaults = {
  :storage => :s3,
  :s3_credentials => {
    :bucket => ENV['AWS_BUCKET'],
    :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
    :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
  }
}

然后,所描述的开发中心文章的作者设置环境变量AWS_BUCKET,AWS_ACCESS_KEY_ID和AWS_SECRET_ACCESS_KEY。

Then, set the environmental variables AWS_BUCKET, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY as described by the author of the dev center article.

这篇关于AWS S3,回形针缺少必要的:斗选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 13:50