开发者

Remote forms not posting paperclip attachments - Rails 3

I have a Tour model with a paperclip 'cover' attachment. When the Tour model is created it will happily upload the file I've selected. It all looks something like this:

<% form_for [@user, @tour], :html => {:multipart => true} do |form| %>
 <%= form.text_field :title %>
 <%= form.file_field :cover %>
 <%= form.text_field :pic_url %>
 <%= form.submit 'go' %>
<% end %>

I've recently re-implemented the edit action of Tou开发者_运维知识库r so the form is posted remotely. I've got the remote form working well posting and updating my form via ajax however when I wish to change the 'cover' image it doesn't change. The remote form looks something like this:

<%= form_for [@user, @tour], :remote => true, :update => "tour_form_holder", :html => {:multipart => true} do |form| %> 
 <%= form.text_field :title %>
 <%= form.file_field :cover %>
 <%= form.text_field :pic_url %>
 <%= form.submit 'go' %>
<% end %>

Looking at the data posted by the form it doesn't seem as though it's posting anything to do with 'cover' - unlike when I posted the form without ajax.

The one thing that does work however, is posting a url to a file using the form. I've set up 'pic_url' to be an alternative to uploading a local file. I know this isn't interfering because I've removed it and tried without it.

I know that Amazon s3 and paperclip are working - it's just something about this remote form that isn't... any ideas?


It is not possible to upload a file via an AJAX request. See here for more details: uploading a file via ajax with php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜