开发者

Can't upload photo using paper clip in RoR

开发者 https://www.devze.com 2022-12-18 08:45 出处:网络
I use this code to upload photos, I find that it is not successfully upload photo, but other content can be updated.

I use this code to upload photos, I find that it is not successfully upload photo, but other content can be updated.

<% semantic_remote_form_for(@product, :html => {:multipart => true}) do |f| %>  
  <% f.inputs do %>  
    <%= f.input :title, :label => "Name"开发者_高级运维 %>  
    <%= f.input :category , :include_blank => false , :label => "Category" %>  
    <%= f.input :price, :label => "Price" %>  
    <%= f.input :photo, :label => "Photo" %>
  <% end %>  
  <%= f.buttons %>  
<% end %>

The code from server log:

DEPRECATION WARNING: Disabling sessions for a single controller has been deprecated. Sessions are now lazy loaded. So if you don't access them, consider them off. You can still modify the session cookie options with request.session_options.. (called from /onlineStore/app/controllers/application_controller.rb:6)

Processing ProductsController#update (for ::1 at 2010-01-23 22:03:54) [PUT] Parameters: {"commit"=>"Save Product", "authenticity_token"=>"vOvxOPYYE1wRGDYTEH5ciHrNJXUpGTJku3etIpCmf1c=", "id"=>"33", "product"=>{"price"=>"874", "title"=>"Other products", "category_id"=>"142"}, "_"=>""}


I'm surprised it worked at all, since Javascript is not supposed to be able to upload files via AJAX. Was the new switch the fact that you made it a remote form for the product? Since even though it's a gem helping with the semantic form building, even it shouldn't be able to do file uploads in that fashion.

0

精彩评论

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

关注公众号