0

I can't get to upload images using paperclip. Whenever I choose the file and submit the page reloads and says "no file chosen".

My code trip.rb

    class Trip < ActiveRecord::Base
       has_many :images
       accepts_nested_attributes_for :images, :allow_destroy => true
       attr_accessible :messages_attributes
    end 

The form

    <%= f.fields_for :images do |image_fields| %> 
       <% if image_fields.object.new_record? %> 
         <%= image_fields.file_field :image %>  
       <% end %> 
    <% end %>

Image.rb

    class Image < ActiveRecord::Base
     belongs_to :trips

     has_attached_file :image, :styles => { :large => "640x480", :medium => "300x300>", :thumb => "100x100" },
     :storage => :s3,
     :bucket => 'Thrill',
     :s3_credentials => {
       :access_key_id => 'XXXXXXXXXXXX',
       :secret_access_key => 'xxxxxxxxxxxxxxxxxxxxx'
     }
    end

And I also have installed gem 'rmagick' in my gem file, which seems to be the solution for many, with similar problem. But not really in my case.

Any ideas what could be wrong ? Thanks!

Update

via rails console

Image.create :image => File.open('c:/sites/thrillb/app/assets/images/srf.jpg')

Not working as well.

 identify.exe: unable to open image `AppData/Local/Temp/stream20120826-41544-1no4
 vdp.jpg': No such file or directory @ error/blob.c/OpenBlob/2641.
 identify.exe: unable to open image `AppData/Local/Temp/stream20120826-41544-1no4
 vdp.jpg': No such file or directory @ error/blob.c/OpenBlob/2641.
 identify.exe: unable to open image `AppData/Local/Temp/stream20120826-41544-1no4
 vdp.jpg': No such file or directory @ error/blob.c/OpenBlob/2641.
 => #<Image id: nil, image_file_name: "srf.jpg", image_content_type: "image/jpeg"
 , image_file_size: 142825, image_updated_at: "2012-08-26 19:28:19", trip_id: nil
 , created_at: nil, updated_at: nil, title: nil, location_id: nil>
em-v
  • 417
  • 1
  • 3
  • 14
  • As a debugging step have you tried to create an Image from console, without going through the (nested) form? e.g. `Image.create :image => File.open('my_img.jpg')` and if so did that work? – Peter Duijnstee Aug 26 '12 at 18:52
  • Nope, that didn't work! See the update. – em-v Aug 26 '12 at 19:34
  • Then at least we know the the form is not the problem ;) Hmm I'm not too familiar with ruby on windows but from your errors it looks like it's having problems either creating files in or reading from your temporary directory, it doesn't look like an rmagick problem to me. I'm afraid I couldn't tell you why though. Hopefully someone with more windows experience will be able to comment. – Peter Duijnstee Aug 26 '12 at 19:39
  • FYI, paperclip doesn't use rmagick, just ImageMagick. You could try something even more basic to narrow down the problem such as running `identify` and `convert` directly through paperclip ex. `Paperclip.run("identify file/name.jpg")`. Additionally comment out amazon s3 while you're trying to figure this out. – vise Aug 26 '12 at 20:13
  • Did you installed rmagic native library under OS? – Mohanraj Aug 27 '12 at 10:54
  • What do you mean by under OS ? :) – em-v Aug 27 '12 at 16:16

1 Answers1

1

Adding - gem "cocaine", "0.3.2" to gemfile solves the issue.

More info here - Paperclip File Not Found Error

Community
  • 1
  • 1
em-v
  • 417
  • 1
  • 3
  • 14