0

When I upload an image using paperclip and s3 storage. The app works fine locally, I've made the required changes to use s3 for heroku, but on heroku the issue remains continues:

Gemfile

ruby '2.0.0'
gem 'rails', '4.0.3'
gem 'aws-s3'
gem 'aws-sdk', '< 2.0'
gem 'paperclip', "~> 3.5.3"

store.rb

class Store < ActiveRecord::Base
  has_attached_file :logo,
  styles: {
  thumb: ["40x40#", :png],
  small: ["400x400>", :png]},
  default_url: "#{Rails.root}/app/assets/images/missing.jpg",
  storage: :s3,
  s3_credentials: "#{Rails.root}/config/s3.yml",
  path: "/store_logos/:style/:id/:filename"
end

config/s3.yml

development:
  bucket: app-dev
  access_key_id: ***********
  secret_access_key: ***************
production:
  bucket: app-pro
  access_key_id: ***********
  secret_access_key: ***************

I tried this link but no luck.

Any help appreciated

Community
  • 1
  • 1
Prashant4224
  • 1,551
  • 1
  • 14
  • 21
  • Are you setting the bucket ? I can't see where it's being set – Kiloreux Sep 10 '15 at 12:05
  • @Kiloreux in `config/s3.yml` I added the bucket credentials – Prashant4224 Sep 10 '15 at 12:07
  • If you are using the AWS SDK, why do you load the AWS S3 gem? Not sure it should matter, but I would only load what you are using. And of course make sure you restart Rails. Otherwise, can you include the full stack trace in your post? – steve klein Sep 10 '15 at 14:07
  • Can you add the full stack trace for the error – bigsolom Sep 10 '15 at 22:22
  • Linking this topic with related topic : http://stackoverflow.com/questions/28374401/nameerror-uninitialized-constant-paperclipstorages3aws – equivalent8 Mar 21 '16 at 13:27

1 Answers1

2

Finally, I got the solution to the issue. Updated the Gemfile and models/store.rb.

Reference document here

Gemfile

ruby '2.0.0'
gem 'rails', '4.0.3'
gem 'aws-s3'
gem 'aws-sdk-v1'
gem 'aws-sdk', '~> 2'

models/store.rb

class Store < ActiveRecord::Base
  require 'aws-sdk-v1'
  require 'aws-sdk'
  has_attached_file :logo,
  styles: {
    thumb: ["40x40#", :png],
    small: ["400x400>", :png]},
    default_url: "#{Rails.root}/app/assets/images/missing.jpg",
    storage: :s3,
    s3_credentials: "#{Rails.root}/config/s3.yml",
    path: "/store_logos/:style/:id/:filename"
end
Prashant4224
  • 1,551
  • 1
  • 14
  • 21