0

我决定将我的应用程序部署到 Heroku 并且我正在关注他们的教程。但是,我现在尝试使用回形针插件连接到我的 Amazon S3 存储桶,但出现此错误:

图片中的参数错误#index

显示第 19 行出现的 app/views/images/index.html.erb:

第 0 行第 39 列的语法错误:`bucket: (MY BUCKET HERE)
access_key_id: (MY ACCESS KEY ID HERE)
secret_access_key: (MY SECRET ACCESS KEY HERE)
'
提取的源代码(在第 19 行附近):

16: <%=h image.created_at %>
17: <%=h image.updated_at %>
18:
19: <% if image.img.exists? 然后 %>
20:

<%= image_tag image.img.url(:thumb) %>


21: <% 其他 %>
22:

没有附照片,上传一张。

RAILS_ROOT: C:/Users/Mariusz/Sites/wiw_development

应用程序跟踪 | 框架跟踪 | 完整跟踪
C:/Ruby/lib/ruby/1.8/yaml.rb:133:in load' C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:236:in parse_credentials' C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:138:in instance_eval' C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib /paperclip/storage.rb:137:in扩展' C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:269:in初始化' C:/Users/Mariusz/Sites /wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:326:in attachment_for'load'
C:/Ruby/lib/ruby/1.8/yaml.rb:133:in

find_credentials'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:176:in

extended'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:137:in

extended'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:269:in

initialize_storage'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:51:in

new'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:326:in

C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:229:in _run_erb_app47views47images47index46html46erb' C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb :12:in _run_erb_app47views47images47index46html46erb' C:/Users/Mariusz/Sites/wiw_development/app/controllers/images_controller.rb:7:in `index' img'
C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:19:in

each'
C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:12:in

我的文件如下所示:

1) 应用程序/模型/image.rb

类图像 < ActiveRecord::Base
has_and_belongs_to_many :pairs
validates_presence_of :img_file_name
has_attached_file :img, :styles => {:thumb=> "100x100#", :page => "400x320>"}, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml"
结束

2) 配置/s3.yml

桶:(我的桶在这里)
access_key_id:(我的访问密钥ID在这里)
secret_access_key:(我的秘密访问密钥)

我怎样才能让它工作?

4

2 回答 2

9

C:/Ruby/lib/ruby/1.8/yaml.rb:133:in load' - 这是 YAML 错误。您可能有一个格式错误的 YML 文件。在您的脚本/控制台中尝试此代码:

require 'yaml'
my_hash = YAML::load File.read("#{RAILS_ROOT}/config/s3.yml")

以下是我的工作配置中的一个示例:

  has_attached_file :data,
  :styles => {
    :small => "100x100#",
    :medium => "400x400#",
    :large => "640x480#"
  },
  :storage => :s3,
  :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
  :path => ":attachment/:id/:style.:extension",
  :bucket => "xxx"

和 yml 文件:

development:
  access_key_id: ***
  secret_access_key: ***
于 2010-01-06T16:39:10.093 回答
0

你是对的。我的“e”文本编辑器将 yaml 文件保存为带有一些附加字符的奇怪格式。现在一切正常。谢谢!

于 2010-01-08T15:32:15.097 回答