Paperclip / Remotipart AJAX上传

时间:2013-11-23 23:42:41

标签: ruby-on-rails ajax paperclip

我正在使用Paperclip和Remotipart来处理一些AJAX文件上传(使用AJAX上传和显示图像)。

我正在使用Rails 3.2.11

问题是,在创建记录时,附件字段都是零,实际上没有图像上传。这是一个小形式:

<%= form_tag("/portfolios/upload_port_img", method: "post", :html => { :multipart => true }, remote: true, :class=>'fileup') do |t| %>
        <% file_field_tag(:attachment) %>       
<% end %>

当我提交表单时,我得到了回复:

Processing by PortfoliosController#upload_port_img as JS
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"+/pPeTYu9filNt5M2+BNYIc9+8kzLyo4pvCB6oMC0U0=", "remotipart_submitted"=>"true", "X-Requested-With"=>"IFrame", "X-Http-Accept"=>"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01", "attachment"=>#<ActionDispatch::Http::UploadedFile:0x00000003417488 @original_filename="6jPQg1l.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"attachment\"; filename=\"6jPQg1l.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20131123-10843-h6wdmc>>}
   (0.1ms)  begin transaction
  SQL (4.3ms)  INSERT INTO "portfolio_files" ("attachment_content_type", "attachment_file_name", "attachment_file_size", "attachment_updated_at", "created_at", "description", "portfolio_id", "position", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)  [["attachment_content_type", nil], ["attachment_file_name", nil], ["attachment_file_size", nil], ["attachment_updated_at", nil], ["created_at", Sat, 23 Nov 2013 23:41:27 UTC +00:00], ["description", nil], ["portfolio_id", nil], ["position", nil], ["updated_at", Sat, 23 Nov 2013 23:41:27 UTC +00:00]]
[paperclip] Saving attachments.
   (9.4ms)  commit transaction
  Rendered portfolios/upload_port_img.js.erb (31.4ms)
Completed 200 OK in 131ms (Views: 69.6ms | ActiveRecord: 14.1ms)

然而,还没有上传图片。知道为什么会这样吗?

0 个答案:

没有答案