与S3 on Rails的回形针3 /未初始化的常量AWS :: S3 ::连接 [英] Paperclip with S3 on Rails 3 / uninitialized constant AWS::S3::Connection
本文介绍了与S3 on Rails的回形针3 /未初始化的常量AWS :: S3 ::连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想上传一个文件使用回形针S3并获得制作一个新的对象和引用变量时,这个错误:
- 在安装了AWS-S3宝石
- 的s3.yml文件具有正确的凭据
例如:
A = Attachment.new
一份文件
NameError:未初始化不断AWS :: S3 ::连接
从/Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in`const_missing'
从/Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3.rb:32
从/Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3.rb:31:in`class_eval
从/Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3.rb:31
从/Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/storage.rb:131:in'扩展'
从/Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/attachment.rb:269:in'延伸'
从/Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/attachment.rb:269:in`initialize_storage
从/Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/attachment.rb:51:in'初始化'
从/Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip.rb:372:in'新'
从/Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip.rb:372:in`attachment_for
从/Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip.rb:270:in'文件'
从(IRB):6
和这里是附件模式是这样的:
类附件<的ActiveRecord :: Base的
belongs_to的:交
has_attached_file:文件,
:存储=> :S3,
:s3_credentials => #{} RAILS_ROOT /config/s3.yml
:PATH => /uploads/:attachment/:id/:style/:basename.:extension
:斗=> bucketname,
:s3_permissions => :public_read
结束
解决方案
竟然是与我已经离开了的Gemfile不同S3宝石冲突
I'm trying to upload a file to s3 using paperclip and get this error when making a new object and referencing the variable:
- the aws-s3 gem is installed
- the s3.yml file has the correct credentials
ie:
a = Attachment.new
a.file
NameError: uninitialized constant AWS::S3::Connection
from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing'
from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3.rb:32
from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3.rb:31:in `class_eval'
from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3.rb:31
from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/storage.rb:131:in `extended'
from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/attachment.rb:269:in `extend'
from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/attachment.rb:269:in `initialize_storage'
from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/attachment.rb:51:in `initialize'
from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip.rb:372:in `new'
from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip.rb:372:in `attachment_for'
from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip.rb:270:in `file'
from (irb):6
and here is what the Attachment model looks like:
class Attachment < ActiveRecord::Base
belongs_to :post
has_attached_file :file,
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => "/uploads/:attachment/:id/:style/:basename.:extension",
:bucket => 'bucketname',
:s3_permissions => :public_read
end
解决方案
turned out to be a conflict with a different s3 gem that i had left in the gemfile
这篇关于与S3 on Rails的回形针3 /未初始化的常量AWS :: S3 ::连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文