I am not exactly sure what I am doing wrong. Paperclip with S3.
Errno::EACCES in ListingsController#update Permission denied @ dir_s_mkdir - /listings Extracted source (around line #44):
- def update
- respond_to do |format|
- if @listing.update(listing_params)
- format.html { redirect_to @listing, notice: 'Listing was 46.successfully updated.' }
- format.json { render :show, status: :ok, location: @listing } 48 else
Listing_controller.rb
<p id="notice"><%= notice %></p>
<div class="row">
<div class="col-md-6">
<div class="thumbnail">
<%= image_tag @listing.image.url %>
</div>
</div>
<div class="col-md-6">
<h3><%= @listing.name %></h3>
<p><%= number_to_currency (@listing.price) %></p>
<p><%= @listing.description %></p>
</div>
</div>
<%= link_to 'Edit', edit_listing_path(@listing), class: "btn btn-link" %>
<%= link_to 'Back', listings_path, class: "btn btn-link" %>
In model,
class Listing < ActiveRecord::Base
has_attached_file :image, :styles => { :medium => "200x", :thumb => "100x100>" }, :default_url => "default.jpg"
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
end
In views, show.html.erb
<p id="notice"><%= notice %></p>
<div class="row">
<div class="col-md-6">
<div class="thumbnail">
<%= image_tag @listing.image.url %>
</div>
</div>
<div class="col-md-6">
<h3><%= @listing.name %></h3>
<p><%= number_to_currency (@listing.price) %></p>
<p><%= @listing.description %></p>
</div>
</div>
<%= link_to 'Edit', edit_listing_path(@listing), class: "btn btn-link" %>
<%= link_to 'Back', listings_path, class: "btn btn-link" %>
Gems installed,
source 'https://rubygems.org'
ruby "2.3.3"
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'rails', '~> 5.0.1'
gem 'puma', '~> 3.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'jquery-rails'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'bootstrap-sass', '~> 3.3.6'
gem "paperclip", git: "git://github.com/thoughtbot/paperclip.git"
gem 'listen', '~> 3.1.5'
gem 'aws-sdk'
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :development, :test do
gem 'sqlite3'
end
group :doc do
gem 'sdoc', require: false
end
Error within Terminal,
Listing Load (5.7ms) SELECT "listings".* FROM "listings" WHERE "listings"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
(0.1ms) begin transaction
[paperclip] Trying to link /var/folders/__/2162ls5577704gd514y0859w0000gp/T/RackMultipart20170210- 36927-1iuewku.jpg to /var/folders/__/2162ls5577704gd514y0859w0000gp/T/c3e768b17c5aa48db8ffbc959904bbaa20170210-36927-1ywsn2q.jpg
[paperclip] Trying to link /var/folders//2162ls5577704gd514y0859w0000gp/T/c3e768b17c5aa48db8ffbc959904bbaa20170210-36927-1ywsn2q.jpg to /var/folders//2162ls5577704gd514y0859w0000gp/T/c3e768b17c5aa48db8ffbc959904bbaa20170210-36927-1t9j57i.jpg Command :: file -b --mime '/var/folders//2162ls5577704gd514y0859w0000gp/T/c3e768b17c5aa48db8ffbc959904bbaa20170210-36927-1t9j57i.jpg' Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders//2162ls5577704gd514y0859w0000gp/T/c3e768b17c5aa48db8ffbc959904bbaa20170210-36927-1ywsn2q.jpg[0]' 2>/dev/null Command :: identify -format %m '/var/folders//2162ls5577704gd514y0859w0000gp/T/c3e768b17c5aa48db8ffbc959904bbaa20170210-36927-1ywsn2q.jpg[0]' Command :: convert '/var/folders//2162ls5577704gd514y0859w0000gp/T/c3e768b17c5aa48db8ffbc959904bbaa20170210-36927-1ywsn2q.jpg[0]' -auto-orient -resize "200" '/var/folders//2162ls5577704gd514y0859w0000gp/T/73570fb1d3ecfa0dc9a9d5e124c5763420170210-36927-j452kb' [paperclip] Trying to link /var/folders//2162ls5577704gd514y0859w0000gp/T/73570fb1d3ecfa0dc9a9d5e124 c5763420170210-36927-j452kb to /var/folders//2162ls5577704gd514y0859w0000gp/T/9918700e8a5840d631b32dff0efdc32820170210-36927-1j9zu6h Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders//2162ls5577704gd514y0859w0000gp/T/c3e768b17c5aa48db8ffbc959904bbaa20170210-36927-1ywsn2q.jpg[0]' 2>/dev/null Command :: identify -format %m '/var/folders//2162ls5577704gd514y0859w0000gp/T/c3e768b17c5aa48db8ffbc959904bbaa20170210-36927-1ywsn2q.jpg[0]' Command :: convert '/var/folders//2162ls5577704gd514y0859w0000gp/T/c3e768b17c5aa48db8ffbc959904bbaa20170210-36927-1ywsn2q.jpg[0]' -auto-orient -resize "100x100>" '/var/folders//2162ls5577704gd514y0859w0000gp/T/73570fb1d3ecfa0dc9a9d5e124c5763420170210-36927-1t64b8q' [paperclip] Trying to link /var/folders//2162ls5577704gd514y0859w0000gp/T/73570fb1d3ecfa0dc9a9d5e124c5763420170210-36927-1t64b8q to /var/folders//2162ls5577704gd514y0859w0000gp/T/5a42e5f066b94471d8d7dd70241f775820170210-36927-1l2vm2j [paperclip] Trying to link /var/folders//2162ls5577704gd514y0859w0000gp/T/c3e768b17c5aa48db8ffbc959904bbaa20170210-36927-1ywsn2q.jpg to /var/folders//2162ls5577704gd514y0859w0000gp/T/c3e768b17c5aa48db8ffbc959904bbaa20170210-36927-h40oj7.jpg Command :: file -b --mime '/var/folders//2162ls5577704gd514y0859w0000gp/T/c3e768b17c5aa48db8ffbc959904bbaa20170210-36927-h40oj7.jpg' SQL (0.9ms) UPDATE "listings" SET "image_file_name" = ?, "image_file_size" = ?, "image_updated_at" = ?, "updated_at" = ? WHERE "listings"."id" = ? [["image_file_name", "022916_flyMG2.jpg"], ["image_file_size", 12403], ["image_updated_at", 2017-02-10 01:24:57 UTC], ["updated_at", 2017-02-10 01:24:58 UTC], ["id", 1]] (1.0ms) rollback transaction Completed 500 Internal Server Error in 457ms (ActiveRecord: 8.6ms)
Errno::EACCES (Permission denied @ dir_s_mkdir - /listings):
app/controllers/listings_controller.rb:44:in `block in update'
app/controllers/listings_controller.rb:43:in `update'
Rendering /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack- 5.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erbwithin rescues/layout
Rendering /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack- 5.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb
Rendered /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (7.4ms)
Rendering /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
Rendered /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (3.6ms)
Rendering /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
Rendered /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (3.5ms)
Rendered /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (152.5ms)
/listings
directory is specified. This is usually in the Paperclip initializer. – tadman