I have decided to deploy my app to Heroku and I was following their tutorials. However, Im trying to connect to my Amazon S3 bucket with a paperclip plugin right now and Im getting this error:
我决定将我的应用程序部署到Heroku,我正在按照他们的教程进行操作。但是,我现在尝试使用回形针插件连接到我的Amazon S3存储桶,我收到此错误:
ArgumentError in Images#index
Images#index中的ArgumentError
Showing app/views/images/index.html.erb where line #19 raised:
显示第19行引发的app / views / images / index.html.erb:
syntax error on line 0, col 39: `bucket: (MY BUCKET HERE)
access_key_id: (MY ACCESS KEY ID HERE)
secret_access_key: (MY SECRET ACCESS KEY HERE)
'
Extracted source (around line #19):第0行,第39栏的语法错误:`bucket:(我的桶在这里)access_key_id :(我的访问密钥ID在这里)secret_access_key :(我的秘密访问密钥在这里)'提取的来源(第19行附近):
16: <%=h image.created_at %>
17: <%=h image.updated_at %>
18:
19: <% if image.img.exists? then %>
20:16:<%= h image.created_at%> 17:<%= h image.updated_at%> 18:19:<%if image.img.exists?那么%> 20:
<%= image_tag image.img.url(:thumb) %>
<%= image_tag image.img.url(:thumb)%>
21: <% else %>
22:There are no photo's attached, upload one.
没有附加照片,上传一张。
RAILS_ROOT: C:/Users/Mariusz/Sites/wiw_development
Application Trace | Framework Trace | Full Trace
C:/Ruby/lib/ruby/1.8/yaml.rb:133:inload'
load'
C:/Ruby/lib/ruby/1.8/yaml.rb:133:in
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:236:infind_credentials'
parse_credentials'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:176:in
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:138:inextended'
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/storage.rb:137:inextended'
extend'
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/attachment.rb:269:ininitialize_storage'
initialize'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:51:in
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:326:innew'
attachment_for'
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:inimg'
_run_erb_app47views47images47index46html46erb'
C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:19:in
C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:12:ineach'
_run_erb_app47views47images47index46html46erb'
C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:12:in
C:/Users/Mariusz/Sites/wiw_development/app/controllers/images_controller.rb:7:in `index'应用程序跟踪|框架跟踪|完整跟踪C:/Ruby/lib/ruby/1.8/yaml.rb:133:在加载'C:/Ruby/lib/ruby/1.8/yaml.rb:133:inload'C:/ Users / Mariusz / Sites / wiw_development / vendor / plugins / paperclip / lib / paperclip / storage.rb:236:在find_credentials'C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:176:inparse_credentials' C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:138:在扩展'C:/ Users / Mariusz / Sites / wiw_development / vendor / plugins / paperclip / lib / paperclip /storage.rb:137:ininstance_eval'C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:137:在扩展'C:/ Users / Mariusz / Sites / wiw_development / vendor / plugins / paperclip / lib / paperclip / attachment.rb:269:不用'C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:269:在initialize_storage'中: /Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:51:ininitialize'C:/ Users / Mariusz / Sites /wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:326:in new'C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:326:inattachment_for'C: /用户/ Mariusz / Sites / wiw_development / vendor / plugins / paperclip / lib / paperclip.rb:229:in img'C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:19: in_run_erb_app47views47images47index46html46erb'C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:12:in each'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'
My files look like this:
我的文件看起来像这样:
1) app/models/image.rb
class Image < 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"
endclass Image
{:thumb =>“100x100#”,:page =>“400x320>”},:storage =>:s3,:s3_credentials >“#{RAILS_ROOT} /config/s3.yml”结束
2) config/s3.yml
bucket: (MY BUCKET HERE)
access_key_id: (MY ACCESS KEY ID HERE)
secret_access_key: (MY SECRET ACCESS KEY HERE)bucket :( MY BUCKET HERE)access_key_id :(我的访问密钥ID在这里)secret_access_key :(我的秘密访问密钥在这里)
How can I get it working?
我怎样才能让它运作起来?
2 个解决方案
#1
9
C:/Ruby/lib/ruby/1.8/yaml.rb:133:in load' - this is a YAML error. You probably have a badly formatted YML file. Try this code in your script/console:
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")
Below is an example from my working config:
以下是我的工作配置中的示例:
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"
And the yml file:
和yml文件:
development:
access_key_id: ***
secret_access_key: ***
#2
0
You were right. My 'e' text editor was saving the yaml file in a strange format with some additional characters. Everything is working right now. THANKS!
你是对的。我的'e'文本编辑器将yaml文件保存为一种奇怪的格式,带有一些额外的字符。现在一切正常。谢谢!
#1
9
C:/Ruby/lib/ruby/1.8/yaml.rb:133:in load' - this is a YAML error. You probably have a badly formatted YML file. Try this code in your script/console:
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")
Below is an example from my working config:
以下是我的工作配置中的示例:
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"
And the yml file:
和yml文件:
development:
access_key_id: ***
secret_access_key: ***
#2
0
You were right. My 'e' text editor was saving the yaml file in a strange format with some additional characters. Everything is working right now. THANKS!
你是对的。我的'e'文本编辑器将yaml文件保存为一种奇怪的格式,带有一些额外的字符。现在一切正常。谢谢!