Ruby on rails 如何更新回形针附件字段记录
我为个人资料页面创建了一个编辑表单,其中包含名字、姓氏和照片Ruby on rails 如何更新回形针附件字段记录,ruby-on-rails,ruby-on-rails-3,paperclip,Ruby On Rails,Ruby On Rails 3,Paperclip,我为个人资料页面创建了一个编辑表单,其中包含名字、姓氏和照片 <%= form_tag "/profiles/update", :html => {:multipart => true} do%> <h4>First Name:</h4> <%= text_field_tag :first_name, @profile.first_name %> <h4>Last Name:</h4>
<%= form_tag "/profiles/update", :html => {:multipart => true} do%>
<h4>First Name:</h4>
<%= text_field_tag :first_name, @profile.first_name %>
<h4>Last Name:</h4>
<%= text_field_tag :last_name, @profile.last_name %>
<h4>Photo</h4>
<%= file_field_tag :photo %>
<%= submit_tag "Save changes" %>
<% end %>
所以,当我运行编辑表单并为文件字段选择新图像,然后提交时,我遇到了这个错误
Paperclip::AdapterRegistry::NoHandlerError in ProfilesController#update
No handler found for "Pic.jpg"
有什么建议这里有什么问题吗?应该是:
<%= form_tag "/products/create", :multipart => true do%>
true do%>
现在可以正常工作了您的
配置文件
中的附加文件
块是什么样子的?附加文件:照片尝试定义缩略图样式。如果这能让它工作,我会用提交一个bug,因为定义一个样式是不必要的。我认为file\u field\u标记的问题在于,在create action中,当我使用“f.file\u field”时,它工作得很好,但当我在update action上使用file\u field\u标记时,它会通过这个错误。在这种情况下,我只需重写表单,使用@profile的form_
,然后从那里开始。
<%= form_tag "/products/create", :multipart => true do%>