AWS-S3 integration with Rails3/CE

168 views
Skip to first unread message

Dave Minor

unread,
Mar 28, 2013, 12:25:58 AM3/28/13
to communi...@googlegroups.com
I'm in the process of upgrading an old CE site. I've moved from Rails 2 to Rails 3 and converted it from attachment_fu to paperclip.  Now I'm working on moving storage to S3 and I'm not able to track down why the AWS::S3 class isn't loading.  I'm grateful for any help in tracking this down and will reply with any further info I need to supply to dig into this. 

CE master branch (as of a few days ago)
Rails 3.2.13
Ruby 1.9.2
gem list (abbreviated):
aws-s3 (0.6.3)
aws-sdk (1.8.5)
paperclip (2.4.5)

1.9.2-p320 :003 > pic
 => #<Photo id: 25, name: "my ride", description: "", created_at: "2009-06-19 00:12:04", updated_at: "2009-06-19 00:16:15", user_id: 1, photo_content_type: "image/jpeg", photo_file_name: "img_0259.jpg", photo_file_size: 27941, parent_id: nil, thumbnail: nil, width: 465, height: 349, album_id: nil, view_count: nil, photo_updated_at: nil>
1.9.2-p320 :004 > pic.photo
NameError: uninitialized constant AWS::S3::Base
    from /Users/dminor/.rvm/gems/ruby-1.9.2-p320/gems/paperclip-2.4.5/lib/paperclip/storage/s3.rb:101:in `block in extended'
    from /Users/dminor/.rvm/gems/ruby-1.9.2-p320/gems/paperclip-2.4.5/lib/paperclip/storage/s3.rb:79:in `instance_eval'
    from /Users/dminor/.rvm/gems/ruby-1.9.2-p320/gems/paperclip-2.4.5/lib/paperclip/storage/s3.rb:79:in `extended'
    from /Users/dminor/.rvm/gems/ruby-1.9.2-p320/gems/paperclip-2.4.5/lib/paperclip/attachment.rb:392:in `extend'
    from /Users/dminor/.rvm/gems/ruby-1.9.2-p320/gems/paperclip-2.4.5/lib/paperclip/attachment.rb:392:in `initialize_storage'
    from /Users/dminor/.rvm/gems/ruby-1.9.2-p320/gems/paperclip-2.4.5/lib/paperclip/attachment.rb:73:in `initialize'
    from /Users/dminor/.rvm/gems/ruby-1.9.2-p320/gems/paperclip-2.4.5/lib/paperclip.rb:448:in `new'
    from /Users/dminor/.rvm/gems/ruby-1.9.2-p320/gems/paperclip-2.4.5/lib/paperclip.rb:448:in `attachment_for'
    from /Users/dminor/.rvm/gems/ruby-1.9.2-p320/gems/paperclip-2.4.5/lib/paperclip.rb:332:in `block in has_attached_file'
    from (irb):4
    from /Users/dminor/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
    from /Users/dminor/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
    from /Users/dminor/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

John Feras

unread,
Mar 28, 2013, 6:49:53 AM3/28/13
to communi...@googlegroups.com
Hi Dave...

I recently went through getting a CE instance up and running with 3.2 .. your problem sounded familiar so I went back through my notes and git log, and found that to resolve I had to specify the S3 gem in my Gemfile in the following way:

gem "aws-s3", :require => "aws/s3"

Hope this helps....

John





--
You received this message because you are subscribed to the Google Groups "CommunityEngine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to communityengi...@googlegroups.com.
To post to this group, send email to communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/communityengine?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Martin Düren

unread,
Mar 28, 2013, 9:07:41 AM3/28/13
to communi...@googlegroups.com, jfe...@ferasinfotech.com
Another thing: For me Paperclip 2.4.5 did not work, I needed to upgrade to Paperclip 2.7.5. See this thread for my S3 setup: https://groups.google.com/forum/?fromgroups=#!topic/communityengine/0H26B9q2YxU

Best of luck!
Martin

Dave Minor

unread,
Mar 28, 2013, 9:34:10 AM3/28/13
to communi...@googlegroups.com
Thank you John.  That got me to an error message I could sort through. 

For posterity, here's the pieces I picked up here and there to make community_engine, paperclip, and S3 all work together:
do not include aws-sdk gem
include aws-s3 like:

gem 'aws-s3', :require => "aws/s3"

In config/application_config.rb, tell paperclip where to find the s3 creds:
  :feature => {
    :use_thumbs => true,
    :dimensions => [150, 635],
    :paperclip_options => {
      :storage => 's3',

      # point paperclip to s3 credentials
      :s3_credentials => Rails.root.join('config', 's3.yml'),

      :styles => {
        :original => '465>',
        :thumb => "45x45#",
        :large => "635x150#"
      }
    },
    :validation_options => {
      :max_size => 3,
      :content_type => ['image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png']
    }
  },


Then in config/s3.yml, update :bucket_name to :bucket for newer version.

HTH
Dave

Dave Minor

unread,
Mar 28, 2013, 9:45:02 AM3/28/13
to communi...@googlegroups.com
Thanks Martin.  I had found that thread and it did help me get it working, although I did not have to upgrade paperclip.  I'm still at 2.4.5 fwiw.


Dave

On Wednesday, March 27, 2013 11:25:58 PM UTC-5, Dave Minor wrote:
Reply all
Reply to author
Forward
0 new messages