1
votes

After installing the paperclip gem successfully,and connecting it to Amazon S3 it does not store the images when i push to heroku. When i upload my image and click on create is gives me application error.

heroku logs -t shows the following

2014-04-07T20:04:05.374648+00:00 app[web.1]: Started GET "/" for 92.5.106.142 at 2014-04-07 20:04:05 +0000
2014-04-07T20:04:05.374648+00:00 app[web.1]: => Run `rails server -h` for more startup options
2014-04-07T20:04:05.374648+00:00 app[web.1]: Started GET "/" for 92.5.106.142 at 2014-04-07 20:04:05 +0000
2014-04-07T20:04:05.467991+00:00 app[web.1]: Processing by PagesController#home as HTML
2014-04-07T20:04:05.467991+00:00 app[web.1]: Processing by PagesController#home as HTML
2014-04-07T20:04:05.518754+00:00 heroku[router]: at=info method=GET path=/ host=pinterestingapp.herokuapp.com request_id=57a2c884-916a-464e-9a0b-8490471270d7 fwd="92.5.106.142" dyno=web.1 connect=2ms service=194ms status=200 bytes=2653
2014-04-07T20:04:05.511399+00:00 app[web.1]: Completed 200 OK in 43ms (Views: 18.4ms | ActiveRecord: 0.0ms)
2014-04-07T20:04:05.507620+00:00 app[web.1]:   Rendered pages/home.html.erb within layouts/application (12.0ms)
2014-04-07T20:04:05.510985+00:00 app[web.1]:   Rendered layouts/_header.html.erb (1.2ms)
2014-04-07T20:04:05.510985+00:00 app[web.1]:   Rendered layouts/_header.html.erb (1.2ms)
2014-04-07T20:04:05.507620+00:00 app[web.1]:   Rendered pages/home.html.erb within layouts/application (12.0ms)
2014-04-07T20:04:05.511399+00:00 app[web.1]: Completed 200 OK in 43ms (Views: 18.4ms | ActiveRecord: 0.0ms)
2014-04-07T20:04:08.693794+00:00 app[web.1]: Started GET "/users/sign_in" for 92.5.106.142 at 2014-04-07 20:04:08 +0000
2014-04-07T20:04:08.700067+00:00 app[web.1]: Processing by Devise::SessionsController#new as HTML
2014-04-07T20:04:08.693645+00:00 app[web.1]: Started GET "/users/sign_in" for 92.5.106.142 at 2014-04-07 20:04:08 +0000
2014-04-07T20:04:08.700494+00:00 app[web.1]: Processing by Devise::SessionsController#new as HTML
2014-04-07T20:04:08.842784+00:00 app[web.1]:   Rendered devise/shared/_links.erb (2.5ms)
2014-04-07T20:04:08.842784+00:00 app[web.1]:   Rendered devise/shared/_links.erb (2.5ms)
2014-04-07T20:04:08.842784+00:00 app[web.1]:   Rendered devise/sessions/new.html.erb within layouts/application (28.1ms)
2014-04-07T20:04:08.842784+00:00 app[web.1]:   Rendered devise/sessions/new.html.erb within layouts/application (28.1ms)
2014-04-07T20:04:08.881663+00:00 heroku[router]: at=info method=GET path=/users/sign_in host=pinterestingapp.herokuapp.com request_id=d609473f-6898-46c3-ac6e-95ed0797ec57 fwd="92.5.106.142" dyno=web.1 connect=2ms service=192ms status=200 bytes=3819
2014-04-07T20:04:08.845056+00:00 app[web.1]:   Rendered layouts/_header.html.erb (1.2ms)
2014-04-07T20:04:08.845562+00:00 app[web.1]: Completed 200 OK in 145ms (Views: 33.1ms | ActiveRecord: 84.9ms)
2014-04-07T20:04:08.845056+00:00 app[web.1]:   Rendered layouts/_header.html.erb (1.2ms)
2014-04-07T20:04:08.845562+00:00 app[web.1]: Completed 200 OK in 145ms (Views: 33.1ms | ActiveRecord: 84.9ms)
2014-04-07T20:04:19.441357+00:00 app[web.1]: Processing by Devise::SessionsController#create as HTML
2014-04-07T20:04:19.432767+00:00 app[web.1]: Started POST "/users/sign_in" for 92.5.106.142 at 2014-04-07 20:04:19 +0000
2014-04-07T20:04:19.432767+00:00 app[web.1]: Started POST "/users/sign_in" for 92.5.106.142 at 2014-04-07 20:04:19 +0000
2014-04-07T20:04:19.441357+00:00 app[web.1]: Processing by Devise::SessionsController#create as HTML
2014-04-07T20:04:19.441357+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "authenticity_token"=>"FmFRTejYVZrPVThDJBIc8m4vOB1SNVkwbOJc+HIpqyA=", "user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
2014-04-07T20:04:19.441357+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "authenticity_token"=>"FmFRTejYVZrPVThDJBIc8m4vOB1SNVkwbOJc+HIpqyA=", "user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
2014-04-07T20:04:19.647427+00:00 heroku[router]: at=info method=POST path=/users/sign_in host=pinterestingapp.herokuapp.com request_id=72b880b3-defc-4bf7-aec8-8652090e00ae fwd="92.5.106.142" dyno=web.1 connect=15ms service=221ms status=302 bytes=1134
2014-04-07T20:04:19.596300+00:00 app[web.1]: Redirected to http://pinterestingapp.herokuapp.com/
2014-04-07T20:04:19.596300+00:00 app[web.1]: Redirected to http://pinterestingapp.herokuapp.com/
2014-04-07T20:04:19.644384+00:00 app[web.1]: Completed 302 Found in 202ms (ActiveRecord: 22.3ms)
2014-04-07T20:04:19.644384+00:00 app[web.1]: Completed 302 Found in 202ms (ActiveRecord: 22.3ms)
2014-04-07T20:04:19.825920+00:00 app[web.1]:   Rendered pages/home.html.erb within layouts/application (3.7ms)
2014-04-07T20:04:19.816307+00:00 app[web.1]: Started GET "/" for 92.5.106.142 at 2014-04-07 20:04:19 +0000
2014-04-07T20:04:19.816307+00:00 app[web.1]: Started GET "/" for 92.5.106.142 at 2014-04-07 20:04:19 +0000
2014-04-07T20:04:19.820794+00:00 app[web.1]: Processing by PagesController#home as HTML
2014-04-07T20:04:19.820794+00:00 app[web.1]: Processing by PagesController#home as HTML
2014-04-07T20:04:19.825920+00:00 app[web.1]:   Rendered pages/home.html.erb within layouts/application (3.7ms)
2014-04-07T20:04:19.827809+00:00 app[web.1]:   Rendered layouts/_header.html.erb (0.9ms)
2014-04-07T20:04:19.827809+00:00 app[web.1]:   Rendered layouts/_header.html.erb (0.9ms)
2014-04-07T20:04:19.832619+00:00 heroku[router]: at=info method=GET path=/ host=pinterestingapp.herokuapp.com request_id=e77ac58a-351e-456a-b720-f927996f337f fwd="92.5.106.142" dyno=web.1 connect=2ms service=20ms status=200 bytes=2925
2014-04-07T20:04:19.828950+00:00 app[web.1]: Completed 200 OK in 8ms (Views: 4.2ms | ActiveRecord: 2.4ms)
2014-04-07T20:04:19.829072+00:00 app[web.1]: Completed 200 OK in 8ms (Views: 4.2ms | ActiveRecord: 2.4ms)
2014-04-07T20:04:29.878849+00:00 app[web.1]: Started GET "/pins/new" for 92.5.106.142 at 2014-04-07 20:04:29 +0000
2014-04-07T20:04:29.878849+00:00 app[web.1]: Started GET "/pins/new" for 92.5.106.142 at 2014-04-07 20:04:29 +0000
2014-04-07T20:04:29.945360+00:00 app[web.1]: Processing by PinsController#new as HTML
2014-04-07T20:04:29.945360+00:00 app[web.1]: Processing by PinsController#new as HTML
2014-04-07T20:04:30.010617+00:00 app[web.1]:   Rendered pins/_form.html.erb (9.6ms)
2014-04-07T20:04:30.011288+00:00 app[web.1]:   Rendered pins/new.html.erb within layouts/application (12.0ms)
2014-04-07T20:04:30.011239+00:00 app[web.1]:   Rendered pins/new.html.erb within layouts/application (12.0ms)
2014-04-07T20:04:30.010617+00:00 app[web.1]:   Rendered pins/_form.html.erb (9.6ms)
2014-04-07T20:04:30.017252+00:00 heroku[router]: at=info method=GET path=/pins/new host=pinterestingapp.herokuapp.com request_id=37ab0679-c5be-492e-b80d-5da3762c5c65 fwd="92.5.106.142" dyno=web.1 connect=1ms service=143ms status=200 bytes=3458
2014-04-07T20:04:30.013889+00:00 app[web.1]:   Rendered layouts/_header.html.erb (1.3ms)
2014-04-07T20:04:30.014510+00:00 app[web.1]: Completed 200 OK in 69ms (Views: 17.7ms | ActiveRecord: 19.9ms)
2014-04-07T20:04:30.013837+00:00 app[web.1]:   Rendered layouts/_header.html.erb (1.3ms)
2014-04-07T20:04:30.014561+00:00 app[web.1]: Completed 200 OK in 69ms (Views: 17.7ms | ActiveRecord: 19.9ms)
2014-04-07T20:05:02.253602+00:00 app[web.1]: Started POST "/pins" for 92.5.106.142 at 2014-04-07 20:05:02 +0000
2014-04-07T20:05:02.253602+00:00 app[web.1]: Started POST "/pins" for 92.5.106.142 at 2014-04-07 20:05:02 +0000
2014-04-07T20:05:02.261118+00:00 app[web.1]: Processing by PinsController#create as HTML
2014-04-07T20:05:02.261186+00:00 app[web.1]: Processing by PinsController#create as HTML
2014-04-07T20:05:02.261364+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "authenticity_token"=>"k/TNJaPpLqOhvlIgWB6ordlrrvzwhizgsvLZ3vs3HTA=", "pin"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x007f2d552e8798 @tempfile=#<Tempfile:/tmp/RackMultipart20140407-2-8vwd1o>, @original_filename="applemac.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"pin[image]\"; filename=\"applemac.jpg\"\r\nContent-Type: image/jpeg\r\n">, "description"=>"Apple Mac!"}, "commit"=>"Create Pin"}
2014-04-07T20:05:02.261490+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "authenticity_token"=>"k/TNJaPpLqOhvlIgWB6ordlrrvzwhizgsvLZ3vs3HTA=", "pin"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x007f2d552e8798 @tempfile=#<Tempfile:/tmp/RackMultipart20140407-2-8vwd1o>, @original_filename="applemac.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"pin[image]\"; filename=\"applemac.jpg\"\r\nContent-Type: image/jpeg\r\n">, "description"=>"Apple Mac!"}, "commit"=>"Create Pin"}
2014-04-07T20:05:02.386481+00:00 app[web.1]: Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl0.jpg[0]' 2>/dev/null
2014-04-07T20:05:02.290026+00:00 app[web.1]: Command :: file -b --mime '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1akmtmf.jpg'
2014-04-07T20:05:02.290026+00:00 app[web.1]: Command :: file -b --mime '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1akmtmf.jpg'
2014-04-07T20:05:02.387307+00:00 app[web.1]: Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl0.jpg[0]' 2>/dev/null
2014-04-07T20:05:02.601154+00:00 app[web.1]: Command :: identify -format %m '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl0.jpg[0]'
2014-04-07T20:05:02.601323+00:00 app[web.1]: Command :: identify -format %m '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl0.jpg[0]'
2014-04-07T20:05:02.653306+00:00 app[web.1]: Command :: convert '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl0.jpg[0]' -auto-orient -resize "300x300>" '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl020140407-2-zb6x3x'
2014-04-07T20:05:02.653306+00:00 app[web.1]: Command :: convert '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl0.jpg[0]' -auto-orient -resize "300x300>" '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl020140407-2-zb6x3x'
2014-04-07T20:05:02.945353+00:00 app[web.1]: Command :: file -b --mime '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl020140407-2-zb6x3x'
2014-04-07T20:05:02.945353+00:00 app[web.1]: Command :: file -b --mime '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl020140407-2-zb6x3x'
2014-04-07T20:05:03.015579+00:00 app[web.1]: Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl0.jpg[0]' 2>/dev/null
2014-04-07T20:05:03.016494+00:00 app[web.1]: Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl0.jpg[0]' 2>/dev/null
2014-04-07T20:05:03.162027+00:00 app[web.1]: Command :: identify -format %m '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl0.jpg[0]'
2014-04-07T20:05:03.162027+00:00 app[web.1]: Command :: identify -format %m '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl0.jpg[0]'
2014-04-07T20:05:03.227157+00:00 app[web.1]: Command :: convert '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl0.jpg[0]' -auto-orient -resize "100x100>" '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl020140407-2-9uiimt'
2014-04-07T20:05:03.227360+00:00 app[web.1]: Command :: convert '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl0.jpg[0]' -auto-orient -resize "100x100>" '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl020140407-2-9uiimt'
2014-04-07T20:05:03.448821+00:00 app[web.1]: Command :: file -b --mime '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl020140407-2-9uiimt'
2014-04-07T20:05:03.448995+00:00 app[web.1]: Command :: file -b --mime '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ff2cl020140407-2-9uiimt'
2014-04-07T20:05:03.497941+00:00 app[web.1]: Command :: file -b --mime '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ghlubo.jpg'
2014-04-07T20:05:03.497941+00:00 app[web.1]: Command :: file -b --mime '/tmp/bff550a70923040c4b8c5098aa7766af20140407-2-1ghlubo.jpg'
2014-04-07T20:05:03.546916+00:00 app[web.1]: [paperclip] saving /pins/images/000/000/005/original/applemac.jpg
2014-04-07T20:05:03.546916+00:00 app[web.1]: [paperclip] saving /pins/images/000/000/005/original/applemac.jpg
2014-04-07T20:05:03.842041+00:00 app[web.1]: Completed 500 Internal Server Error in 1580ms
2014-04-07T20:05:03.844460+00:00 app[web.1]: 
2014-04-07T20:05:03.842041+00:00 app[web.1]: Completed 500 Internal Server Error in 1580ms
2014-04-07T20:05:03.844460+00:00 app[web.1]:   app/controllers/pins_controller.rb:27:in `create'
2014-04-07T20:05:03.844460+00:00 app[web.1]: ArgumentError (missing required :bucket option):
2014-04-07T20:05:03.844460+00:00 app[web.1]: 
2014-04-07T20:05:03.844460+00:00 app[web.1]: ArgumentError (missing required :bucket option):
2014-04-07T20:05:03.844460+00:00 app[web.1]: 
2014-04-07T20:05:03.844460+00:00 app[web.1]: 
2014-04-07T20:05:03.844460+00:00 app[web.1]: 
2014-04-07T20:05:03.844460+00:00 app[web.1]:   app/controllers/pins_controller.rb:27:in `create'
2014-04-07T20:05:03.844460+00:00 app[web.1]: 
2014-04-07T20:05:03.849242+00:00 heroku[router]: at=info method=POST path=/pins host=pinterestingapp.herokuapp.com request_id=859f05f3-6060-4d15-8ebf-817caaea3663 fwd="92.5.106.142" dyno=web.1 connect=2ms service=17611ms status=500 bytes=1543

it is showing an internal error in my pins.controller.rb create line but do not understand ArgumentError (missing required :bucket option):

i have added params.require(:pin).permit(:description, :image) in my def parms

pins.controller.rb

class PinsController < ApplicationController
  before_action :set_pin, only: [:show, :edit, :update, :destroy]
  before_action :correct_user, only: [:edit, :update, :destroy]
  before_action :authenticate_user!, except: [:index, :show]


  def index
    @pins = Pin.all
  end


  def show
  end


  def new
    @pin = current_user.pins.build
  end


  def edit
  end


  def create
    @pin = current_user.pins.build(pin_params)
      if @pin.save
        redirect_to @pin, notice: 'Pin was successfully created.'
      else
        render action: 'new'
      end
  end


  def update

      if @pin.update(pin_params)
        redirect_to @pin, notice: 'Pin was successfully updated.'
      else
        render action: 'edit'
      end
  end

  def destroy
    @pin.destroy
      redirect_to pins_url
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_pin
      @pin = Pin.find(params[:id])
    end

    def correct_user
      @pin = current_user.pins.find_by(id: params[:id])
      redirect_to pins_path, notice: "Not Authorised to Edit this pin" if @pin.nil?
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def pin_params
      params.require(:pin).permit(:description, :image)
    end
end

production.rb

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']
  }
2
Have you configured the value of ENV['S3_BUCKET_NAME'] in the configuration?Kirti Thorat

2 Answers

1
votes

:bucket needs to be defined outside the :s3_credentials:

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']
  }
}
1
votes

Add the bucket name property to your heroku configuration by running the following command:

heroku config:add S3_BUCKET_NAME=bucket_name_value

For more information: Heroku: Config-Vars