问题描述
我已经决定部署我的应用程序Heroku和我跟随他们的教程。但是,我试着去,现在连接到我的Amazon S3的桶回形针插件和进出口收到此错误:
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:
时ArgumentError在图像#指数
显示应用程序/视图/图片/ index.html.erb,其中线#19提出的:
Showing app/views/images/index.html.erb where line #19 raised:
语法错误就行0,列39:`斗:(MY桶HERE)
access_key_id:(我的访问密钥ID HERE)
secret_access_key:(我的秘密访问键的位置)
提取的源(左右线#19):
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):
16:或其;%= H image.created_at%>
17:或其;%= H image.updated_at%>
18:
19:<如果image.img.exists%?那么%>
20:
<%= image_tag image.img.url(:拇指)%>
16: <%=h image.created_at %>
17: <%=h image.updated_at %>
18:
19: <% if image.img.exists? then %>
20:
<%= image_tag image.img.url(:thumb) %>
有没有照片的连接,上传一个。
There are no photo's attached, upload one.
RAILS_ROOT:C:/用户/马里乌什/网站/ wiw_development
RAILS_ROOT: C:/Users/Mariusz/Sites/wiw_development
应用程序跟踪|框架追踪|完整曲线
C:/Ruby/lib/ruby/1.8/yaml.rb:133:在负荷
负荷
C:/Ruby/lib/ruby/1.8/yaml.rb:133:在
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:in$c$c>parse_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:in$c$c>instance_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:in$c$c>extend'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:269:在 initialize_storage
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:51:in$c$c>initialize'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:326:在新
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:326:in$c$c>attachment_for'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:229:在 IMG
C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:19:in$c$c>_run_erb_app47views47images47index46html46erb'
C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:12:在每个
C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:12:in$c$c>_run_erb_app47views47images47index46html46erb'
C:/Users/Mariusz/Sites/wiw_development/app/controllers/images_controller.rb:7:`指数
Application Trace | Framework Trace | Full Trace
C:/Ruby/lib/ruby/1.8/yaml.rb:133:in load'
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:in find_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:in extended'
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:in extended'
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:in initialize_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:in new'
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:in img'
_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:in each'
_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'
我的文件是这样的:
1)应用程序/模型/ image.rb
1) app/models/image.rb
类图片&LT;的ActiveRecord :: Base的
has_and_belongs_to_many:对
validates_ presence_of:img_file_name
has_attached_file:IMG,:风格=> {:拇指=>100×100#,:页=>400x320>}:存储=>:S3,:s3_credentials =>#{} RAILS_ROOT /config/s3.yml
结束
2)配置/ s3.yml
2) config/s3.yml
斗:(MY桶HERE)
access_key_id:(我的访问密钥ID HERE)
secret_access_key:(我的秘密访问键的位置)
我怎样才能得到它的工作?
How can I get it working?
推荐答案
C:/Ruby/lib/ruby/1.8/yaml.rb:133:负荷 - 这是一个YAML错误。你可能有一个格式错误的YML文件。试试这个code在脚本/控制台:
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:
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:
development:
access_key_id: ***
secret_access_key: ***
这篇关于回报率:无法回形针连接到Amazon S3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!