Rails的回形针IMG上传错误:安装了rmagick“没有选择文件”(Rails papercli

2019-11-01 01:08发布

我无法用回形针上传图片。 每当我选择文件并提交页面重新加载并说:“没有文件选择”。

我的代码trip.rb

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

表格

    <%= 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

而我也有我的宝石文件中,这似乎是许多的解决方案,类似的问题已安装宝石“rmagick”。 但对我来说不是真的。

任何想法可能是错误的? 谢谢!

更新

通过轨道控制台

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

没有达到预期效果。

 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>

Answer 1:

加入- gem "cocaine", "0.3.2"到Gemfile中解决了这个问题。

这里更多的信息- 回形针文件未找到错误



文章来源: Rails paperclip img upload error: “no file chosen” with rmagick installed