Uploading error with attachment_fu and rmagick

I wrote a small app, rails 2.0.2 using attachment_fu and rmagick to upload files. Everthing works fine in my dev machine ( windows XP ). I can upload with no problem.

   I am using deprec/capistrano to deploy to my slicehost account. Everthing works fine, but when I try to upload a file, I was getting the "We're sorry, but something went wrong.", so I delete the 500.html error file from the public folder. I wana see the error, but now, I got a blank page.

I got this blank page with PNG and JPG, but uploading BMP´s file I got the error message:

"1 error prohibited this image from being saved There were problems with the following fields:     * Content type is not included in the list "

  I am using mongrel/nginx.

  How can I see the error message ?

  This is my new.html.erb

Upload New Photo: <%= error_messages_for :image %> <% form_for(:image, :url => product_images_path, :html => { :multipart => true }) do |f| %> Select File: <%= f.file_field :uploaded_data %> Description: <%= f.text_area :description %> <%= submit_tag 'Upload image' %> <% end %>

  I ran this convert -version, to check my imagemagick version:

Version: ImageMagick 6.2.4 10/02/07 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2005 ImageMagick Studio LLC

I have rmagick 1.15.12 installed.

I think this issue, is due something wrong at my slicehost installation.

Thanks in advance.

I a newbie at rails and linux, maybe I have an issue with nginx or some rights have to be granted to create images and folder, as u can see, attachment_fu will try to save them at public/uploads folder, here is my images model.

class Image < ActiveRecord::Base

  has_attachment :content_type => :image,                  :path_prefix => 'public/uploads',                  :storage => :file_system,                  :size => 0.megabyte..2.megabytes,                  :resize_to => '450x450>',                  :thumbnails => { :thumb => '150x150>' },                  :processor => 'Rmagick'

validates_as_attachment   belongs_to :product

end

hi Jose,

give a peek at the log file, perhaps it can help you.

check RAILS_ROOT/log/

felipe mesquita http://felipemesquita.com

could try running it in dev mode temporarily Jose carlos Da cunha jr wrote:

Felipe Mesquita wrote:

hi Jose,

give a peek at the log file, perhaps it can help you.

check RAILS_ROOT/log/

felipe mesquita http://felipemesquita.com

On Wed, Apr 16, 2008 at 3:37 PM, Jose carlos Da cunha jr <

  I was just looking for the log and found this: It seems to be a permission issue... but there is another thing that I doesn't understand... my application is running at releases/20080416173337/ folder? it shouldn´t be at the myapp/current ?

Processing ImagesController#create (for 189.27.163.107 at 2008-04-16 19:21:30) [POST]   Session ID: BAh7CToMdXNlcl9pZGkGOgxjc3JmX2lkIiU5YjQzMDIzOGQzNjc5NDA5NjFj%0AMTVjNDZkYTBlZTg2OSIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxh%0Ac2g6OkZsYXNoSGFz$   Parameters: {"commit"=>"Envia imagem", "authenticity_token"=>"804ab9630d161a1f68c8ef9ac743c62fe198ec41", "product_id"=>"natasha-moore", "action"=>"create"$

Errno::EACCES (Permission denied - /var/www/apps/nanistore/releases/20080416173337/public/uploads/0000):     /usr/local/lib/ruby/1.8/fileutils.rb:243:in `mkdir'     /usr/local/lib/ruby/1.8/fileutils.rb:243:in `fu_mkdir'     /usr/local/lib/ruby/1.8/fileutils.rb:217:in `mkdir_p'     /usr/local/lib/ruby/1.8/fileutils.rb:215:in `reverse_each'     /usr/local/lib/ruby/1.8/fileutils.rb:215:in `mkdir_p'     /usr/local/lib/ruby/1.8/fileutils.rb:201:in `each'     /usr/local/lib/ruby/1.8/fileutils.rb:201:in `mkdir_p'     /vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb:83:in `save_to_storage'     /vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:425:in `after_process_attachment'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:307:in `send'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:307:in `callback'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:304:in `each'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:304:in `callback'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:214:in `create_or_update'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1978:in `save_without_validation!'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/validations.rb:944:in `save_without_transactions!'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:112:in `save!'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in `transaction'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:80:in `transaction'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:100:in `transaction'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:112:in `save!'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:120:in `rollback_active_record_state!'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/transactions.rb:112:in `save!'     /vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:253:in `create_or_update_thumbnail'     /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/object/misc.rb:28:in `returning'     /vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:245:in `create_or_update_thumbnail'     /vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:423:in `after_process_attachment'     /vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:423:in `each'     /vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:423:in `after_process_attachment'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:307:in `send'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:307:in `callback'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:304:in `each'     /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:304:in `callback'

symbolic link? :wink:

felipe mesquita http://felipemesquita.com

Errno::EACCES (Permission denied - /var/www/apps/nanistore/releases/20080416173337/public/uploads/0000):     /usr/local/lib/ruby/1.8/fileutils.rb:243:in `mkdir'     /usr/local/lib/ruby/1.8/fileutils.rb:243:in `fu_mkdir'     /usr/local/lib/ruby/1.8/fileutils.rb:217:in `mkdir_p'     /usr/local/lib/ruby/1.8/fileutils.rb:215:in `reverse_each'     /usr/local/lib/ruby/1.8/fileutils.rb:215:in `mkdir_p'     /usr/local/lib/ruby/1.8/fileutils.rb:201:in `each'     /usr/local/lib/ruby/1.8/fileutils.rb:201:in `mkdir_p'     /vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends

typically need to run it as sudo to avoid those

Roger Pack wrote:

Errno::EACCES (Permission denied - /var/www/apps/nanistore/releases/20080416173337/public/uploads/0000):     /usr/local/lib/ruby/1.8/fileutils.rb:243:in `mkdir'     /usr/local/lib/ruby/1.8/fileutils.rb:243:in `fu_mkdir'     /usr/local/lib/ruby/1.8/fileutils.rb:217:in `mkdir_p'     /usr/local/lib/ruby/1.8/fileutils.rb:215:in `reverse_each'     /usr/local/lib/ruby/1.8/fileutils.rb:215:in `mkdir_p'     /usr/local/lib/ruby/1.8/fileutils.rb:201:in `each'     /usr/local/lib/ruby/1.8/fileutils.rb:201:in `mkdir_p'     /vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends

typically need to run it as sudo to avoid those

  I don't know how to run it as sudo, inside my rails app.

  What I did and it worked was run "chmod 777 uploads" command, so I gave full access to the directory.

  I am not sure this is the best way, but it works, while a look for way to fix it.

  There is something odd here, where should my app run? I have a current folder and several releases folder. Why my app is pointing to a specific release 20080416173337 folder?

  I am using capistrano/deprec, they are awesome. But I must understand a little bit more about them. :wink:

  Anyway, I google lots of attachment_fu tutorial, didn´t see nobody complaing about this permission denied.

Thanks for your help.

/var/www/apps/nanistore/releases/20080416173337/public/uploads/0000):

My guess is that capistrano is using a timestamp to have different copies of your app in your server. Looks to me like you need to make sure that the permissions on public/uploads/0000 allow for the apache user [or whomever] to write to it. Possibly they got created by the capistrano user and apache user doesn't have write access or what not