0 amazon ruby-on-rails amazon-s3 paperclip ruby-on-rails-plugins
我决定将我的应用程序部署到Heroku,我正在关注他们的教程.但是,我现在尝试使用回形针插件连接到我的Amazon S3存储桶,我收到此错误:
Images#index中的ArgumentError
显示第19行引发的app/views/images/index.html.erb:
第0行,第39栏的语法错误:`bucket:(MY BUCKET HERE)
access_key_id :(我的访问密钥ID在这里)
secret_access_key :(我的秘密访问密钥在这里)
'
提取的来源(第19行附近):16:<%= H image.created_at%>
17:<%= H image.updated_at%>
18:
19:<%如果image.img.exists?然后%>
20:<%= image_tag image.img.url(:thumb)%>
21:<%else%>
22:没有附上照片,上传一张.
RAILS_ROOT:C:/ Users/Mariusz/Sites/wiw_development
应用程序跟踪| 框架跟踪| 完整跟踪
C:/Ruby/lib/ruby/1.8/yaml.rb:133:在加载' 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:在初始化' C:/用户/马里乌什/站点/wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:326:in attachment_for'load'
C:/Ruby/lib/ruby/1.8/yaml.rb:133:infind_credentials'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:176:inextended'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:137:inextended'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:269:ininitialize_storage'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:51:innew'
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:在_run_erb_app47views47images47index46html46erb'C :/Users/Mariusz/Sites/wiw_development/app/controllers/images_controller.rb:7:在'index'中img'
C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:19:ineach'
C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:12:in
我的文件看起来像这样:
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"
结束
2)config/s3.yml
bucket :( MY BUCKET HERE)
access_key_id :(我的访问密钥ID在这里)
secret_access_key :(我的秘密访问密钥在这里)
我怎样才能让它运转起来?
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")
Run Code Online (Sandbox Code Playgroud)
以下是我的工作配置中的示例:
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"
Run Code Online (Sandbox Code Playgroud)
和yml文件:
development:
access_key_id: ***
secret_access_key: ***
Run Code Online (Sandbox Code Playgroud)