Paperclip with S3 on Rails 3 / uninitialized constant AWS::S3::Connection

℡╲_俬逩灬. 提交于 2019-12-10 04:21:30

问题


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

回答1:


turned out to be a conflict with a different s3 gem that i had left in the gemfile




回答2:


Mike, did you successfully get aws-s3 working with Rails 3? I am assuming yes, but can you verify as I need to check that out myself.



来源:https://stackoverflow.com/questions/3613741/paperclip-with-s3-on-rails-3-uninitialized-constant-awss3connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!