0

Hello I have just recently deployed my application on heroku and I have gotten an error that reads "We're sorry, but something went wrong." each time when I try to add an avatar image to a part in either its edit or create forms. I have the following gems installed(paperclip and aws) and have also have Amazon web services credentials stored.

UPDATE forgot to include my paperclip configs

config.paperclip_defaults = {
    :storage => :s3,
    :s3_credentials => {
    :bucket => ENV['S3_BUCKET_NAME'],
    :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
    :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'],
    :s3_region => ENV['AWS_REGION'],
    }

I have set a region for my bucket and all other credentials set.

Here are some more of my logs from paper trail

May 06 17:26:29 blooming-stream-56631 app/web.1:    User Load (0.8ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 3]] 
May 06 17:26:29 blooming-stream-56631 app/web.1:    Cart Load (0.6ms)  SELECT  "carts".* FROM "carts" WHERE "carts"."user_id" = $1 LIMIT 1  [["user_id", 3]] 
May 06 17:26:29 blooming-stream-56631 app/web.1:    Part Load (0.6ms)  SELECT  "parts".* FROM "parts" WHERE "parts"."active" = $1 AND "parts"."id" = $2 LIMIT 1  [["active", "t"], ["id", 3]] 
May 06 17:26:29 blooming-stream-56631 app/web.1:     (2.0ms)  BEGIN 
May 06 17:26:29 blooming-stream-56631 app/web.1:  Command :: file -b --mime '/tmp/9a5736fc6ab3ef6c4c315e0672d4cd2820160507-3-egfg1e.jpg' 
May 06 17:26:29 blooming-stream-56631 app/web.1:  Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/9a5736fc6ab3ef6c4c315e0672d4cd2820160507-3-nim88m.jpg[0]' 2>/dev/null 
May 06 17:26:29 blooming-stream-56631 app/web.1:  Command :: identify -format %m '/tmp/9a5736fc6ab3ef6c4c315e0672d4cd2820160507-3-nim88m.jpg[0]' 
May 06 17:26:29 blooming-stream-56631 app/web.1:  Command :: convert '/tmp/9a5736fc6ab3ef6c4c315e0672d4cd2820160507-3-nim88m.jpg[0]' -auto-orient -resize "100x100>" '/tmp/64590094a1bc5d8dad223b9548f3160320160507-3-8wa2ey' 
May 06 17:26:29 blooming-stream-56631 app/web.1:  Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/9a5736fc6ab3ef6c4c315e0672d4cd2820160507-3-nim88m.jpg[0]' 2>/dev/null 
May 06 17:26:29 blooming-stream-56631 app/web.1:  Command :: identify -format %m '/tmp/9a5736fc6ab3ef6c4c315e0672d4cd2820160507-3-nim88m.jpg[0]' 
May 06 17:26:29 blooming-stream-56631 app/web.1:  Command :: convert '/tmp/9a5736fc6ab3ef6c4c315e0672d4cd2820160507-3-nim88m.jpg[0]' -auto-orient -resize "x200" -crop "200x200+39+0" +repage '/tmp/64590094a1bc5d8dad223b9548f3160320160507-3-1897liw' 
May 06 17:26:29 blooming-stream-56631 app/web.1:  Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/9a5736fc6ab3ef6c4c315e0672d4cd2820160507-3-nim88m.jpg[0]' 2>/dev/null 
May 06 17:26:29 blooming-stream-56631 app/web.1:  Command :: identify -format %m '/tmp/9a5736fc6ab3ef6c4c315e0672d4cd2820160507-3-nim88m.jpg[0]' 
May 06 17:26:29 blooming-stream-56631 app/web.1:  Command :: convert '/tmp/9a5736fc6ab3ef6c4c315e0672d4cd2820160507-3-nim88m.jpg[0]' -auto-orient -resize "300x300>" '/tmp/64590094a1bc5d8dad223b9548f3160320160507-3-jmofxi' 
May 06 17:26:29 blooming-stream-56631 app/web.1:  Command :: file -b --mime '/tmp/9a5736fc6ab3ef6c4c315e0672d4cd2820160507-3-71n03p.jpg' 
May 06 17:26:29 blooming-stream-56631 app/web.1:    SQL (0.7ms)  UPDATE "parts" SET "avatar_file_name" = $1, "avatar_content_type" = $2, "avatar_file_size" = $3, "avatar_updated_at" = $4 WHERE "parts"."id" = $5  [["avatar_file_name", "car-parts-tampa.jpg"], ["avatar_content_type", "image/jpeg"], ["avatar_file_size", 66700], ["avatar_updated_at", "2016-05-07 00:26:29.247325"], ["id", 3]] 
May 06 17:26:29 blooming-stream-56631 app/web.1:  [paperclip] saving /parts/avatars/000/000/003/original/car-parts-tampa.jpg 
May 06 17:26:29 blooming-stream-56631 app/web.1:     (0.6ms)  ROLLBACK 
May 06 17:26:29 blooming-stream-56631 app/web.1:  Completed 500 Internal Server Error in 231ms (ActiveRecord: 5.4ms) 
May 06 17:26:29 blooming-stream-56631 app/web.1:  NameError (uninitialized constant Paperclip::Storage::S3::AWS): 
May 06 17:26:29 blooming-stream-56631 app/web.1:    app/controllers/parts_controller.rb:31:in `update' 
May 06 17:26:29 blooming-stream-56631 heroku/router:  at=info method=POST path="/parts/3" host=blooming-stream-56631.herokuapp.com request_id=4002a6c5-61df-46db-9d28-0a49cc679a7f fwd="67.85.136.99" dyno=web.1 connect=2ms service=486ms status=500 bytes=1754 

Gems

gem 'paperclip'
gem 'aws-sdk', '~> 2.3'

Part model

class Part < ActiveRecord::Base
  has_attached_file :avatar, styles: {
    thumb: '100x100>',
    square: '200x200#',
    medium: '300x300>'
  }

  validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/

Part view(create)

<%= form_for(@part, multipart: true) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %><br>


<%= f.label :description %>
<%= f.text_field :description%><br>

<%= f.label :category_id%>
<%= f.collection_select :category_id, Category.all, :id, :name%><br>

<%= f.label :discount%>
<%= f.number_field :discount%>%<br>

<%= f.label :price%>
<%= f.text_field :price%><br>

<div class="field">
  <%= f.label :avatar%>
  <%= f.file_field :avatar%>
</div>
<%=f.submit %>
<%end%>

If anyone needs more information I'll be happy to provide an update.

Dan
  • 179
  • 4
  • 15
  • do you have rails_12factor installed? – ruby_newbie May 06 '16 at 22:34
  • @ruby_newbie just installed it and still getting the same error – Dan May 06 '16 at 22:38
  • @Dan Have you run migrations? What does your paperclip config look like? Have you set a region? Also, please include more of your logs, there should be some more useful information than what you posted. – James Milani May 06 '16 at 23:51
  • @JamesMilani Yep I did run migrations I provided the config and also some more logs from paper trail. I also did set a region – Dan May 07 '16 at 00:33
  • This may help: http://stackoverflow.com/questions/28374401/nameerror-uninitialized-constant-paperclipstorages3aws – pgaspar May 07 '16 at 01:09
  • @pgaspar tried that already didn't work – Dan May 07 '16 at 13:02

2 Answers2

0

Try making your credentials their own hash without including the other elements. Like this:

config.paperclip_defaults = {
    :storage => :s3,
    :bucket => ENV['S3_BUCKET_NAME'],
    :s3_credentials => {
      :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
      :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
    },
    :s3_region => ENV['AWS_REGION']
}

Also, don't forget to set your ENV variables in heroku!

James Milani
  • 1,921
  • 2
  • 16
  • 26
  • I redid the hash as you posted and even re did the ENV variables and still not working :( – Dan May 07 '16 at 13:02
0

Ok it turns out I was setting the region incorrectly I got it to work by changing the region to the proper format they were looking for

Dan
  • 179
  • 4
  • 15