gpt4 book ai didi

javascript - gem 'remotipart' 在服务器 Rails 4 中不显示错误

转载 作者:行者123 更新时间:2023-12-03 10:13:00 26 4
gpt4 key购买 nike

我在我的 gemfile 中使用它:gem 'remotipart'

在我的表单 View new.html.erb中定义

<%=form_for @user, remote: true, html: { multipart: true, class: 'user-form' } do |f| %>

<div id='file_browse'>
<%= f.file_field :image, :id => 'file_browse' %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<%end%>

Controller 方法:

def create
respond_to do |format|
if @user.save
format.js
end
end
end

和我的create.js.erb

<% if remotipart_submitted? %>
alert('submitted via remotipart')
<% else %>
alert('error in uploading image')
<% end %>

它在服务器中给出此错误413:请求实体太大,但没有在页面中显示它,它没有获取我的警报消息,即无法捕获错误。请帮我找到方法。不想给这个 client_max_body_size 2M;使用 Rails 应用程序处理其错误,它从 nginx 请求获取错误不会通过 Rails 应用程序

最佳答案

您从 ngnix 而不是从 Rails 收到此错误。

您可以通过更改 Nginx 配置中的 client_max_body_size 属性来修复此错误。

查看此article了解更多详情。

关于javascript - gem 'remotipart' 在服务器 Rails 4 中不显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30024839/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com