文件上传很好,表单提交通过Paperclip附件完成,但是它应该通过ajax呈现的部分在新页面上显示为文本,而不是呈现模态部分。否则,如果没有Paperclip附件,表单也会正常通过,但部分也会正常呈现。这是显示在页面上的内容,代码为文本:
$("#actionEdit").html("Thank you, application received :) \n\n<br><br>\n\nYou will receive an Update regarding your application within one business day.\n");
它显示在http://localhost:3000/support_tickets.js这是错误的,应该只是localhost。虽然上传了图片,但表格正常提交。如果没有附件,则页面正常呈现。
形式:
<div class="form-group">
<%= f.input :house_insurance_image, hint: "Upload a picture of your house insurance if you plan on holding an event at your house." %>
</div>
控制器:
def create
@support_ticket = current_fan.support_tickets.build(support_ticket_params)
authorize @support_ticket, :create?
@fan = Fan.find(@support_ticket.fan_id)
respond_to do |format|
format.js
end
end
create.js
...
<% elsif @support_ticket.save %>
$("#actionEdit").html("<%= j render 'success' %>");
<% end %>
答案 0 :(得分:0)
问题是我在一个模态中上传,这需要gem remotipart。