问题描述
我正在开发一个Rails应用程序。我有一个表单,用户可以提交一些文件。表单正在执行AJAX调用(它具有remote:true属性)。无论何时我想使用f.file_field:banner助手发送文件,服务器都会响应
缺少模板帖子/用{:locale => [:fr],:formats => [:html],:variants => [],:handlers => [:erb,:builder,:raw,:ruby,:瘦]}。搜索:...
我试着将一个respond_to块添加到我的控制器中,然后服务器抛出一个ActionController :: UnknownFormat。
为什么当我提交一个文件时,它不会渲染我的JS模板?当我提交文本时,表单工作正常。
感谢您的帮助!
编辑:
我的表单:
= bootstrap_form_for @section,remote:true do | f |
= f.file_field:banner
...
我的控制器:
#PATCH / PUT / sections / 1
def update
@ section.update(section_params)
manage_photos
renderposts / update
end
解决方案:
使用!
I am working on a Rails app. I have a form where the user can submit some files. The form is doing an AJAX call (it has the remote: true attribute). Whenever I want to send a file using the "f.file_field :banner" helper, the server responds with
Missing template posts/update with {:locale=>[:fr], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :slim]}. Searched in: ...
I have tried to add a respond_to block into my controller but then the server throws an ActionController::UnknownFormat.
Why is it not rendering my JS template ONLY when I submit a file? The form works fine when I just submit text.
Thank you for you help!
EDIT:
My form:
= bootstrap_form_for @section, remote: true do |f|
= f.file_field :banner
...
My controller:
# PATCH/PUT /sections/1
def update
@section.update(section_params)
manage_photos
render "posts/update"
end
Solution:Using the remotipart gem !
这篇关于使用Paperclip上传文件时缺少模板(仅当form为remote时:true)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!