Rails 回形针 img 上传错误:“未选择文件"安装了 rmagick [英] Rails paperclip img upload error: "no file chosen" with rmagick installed

查看:55
本文介绍了Rails 回形针 img 上传错误:“未选择文件"安装了 rmagick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用回形针上传图片.每当我选择文件并提交页面时,都会重新加载并显示未选择文件".

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

我的代码trip.rb

My code 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 %>

图片.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

而且我还在我的 gem 文件中安装了 gem 'rmagick',这似乎是许多有类似问题的解决方案.但在我的情况下并非如此.

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!

更新

通过 rails 控制台

via rails console

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>

推荐答案

添加 - gem "cocaine", "0.3.2" 到 gemfile 解决了这个问题.

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

此处有更多信息 - 未找到纸夹文件错误

这篇关于Rails 回形针 img 上传错误:“未选择文件"安装了 rmagick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆