ruby-on-rails - Rails 5.2升级导致ErrorController失败,并显示通用错误页面

标签 ruby-on-rails error-handling ruby-on-rails-5

我们正在从Rails 4升级到Rails 5.2,并且自定义错误页面已开始失败。到目前为止,这仅在我们的质量检查服务器上发生。如果我将开发环境设置为显示错误页面,则它们可以正常工作。

日志显示:

Processing by ErrorsController#not_found as HTML
Parameters: {"path"=>"does_not_exist"}
Rendering errors/not_found.html.haml
Rendered errors/not_found.html.haml (3.4ms)
Completed 500 Internal Server Error in 5ms (ActiveRecord: 0.0ms)

页面响应是一条普通的,无样式的通用消息:
500 Internal Server Error
If you are the administrator of this website, then please read this web application's log file and/or the web server's log file to find out what went wrong.

ErrorsController中的相关方法是:
class ErrorsController < ApplicationController

  def not_found
    error_tracking("404")
    fix_request_format

    respond_to do |format|
      format.html { render template: 'errors/not_found', :layout => false, status: 404 }
      format.all { render nothing: true, status: 404 }
    end
  end

模板渲染后会导致500错误的原因是什么?

最佳答案

对于遇到类似问题的任何人,我最终都会查看服务器上的系统日志。在我的发行版上:

sudo tail -f /var/log/messages

这产生了缺少的Ruby错误:
Error during failsafe response: The asset "application_split2" is not present in the asset pipeline.

这为我提供了解决此问题的起点。

关于ruby-on-rails - Rails 5.2升级导致ErrorController失败,并显示通用错误页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56873705/

相关文章:

ruby-on-rails - 在 WHERE 中重构具有两个子选择的查询

ruby-on-rails - Rails 3 回形针上传 : Save Uploaded Object Attachments Before Saving Object

c# - 当发生错误时,我们如何从ServiceStack的JSON Serializer访问数据?

unix - 我应该在 Unix 上为 errno 使用 system_category 还是 generic_category?

ruby-on-rails - 如何将现有模型(包括插入的行)从可空列迁移到不可空列

ruby-on-rails - 以 rails 形式在循环内嵌套属性的字段

javascript - Turbolinks 消灭了 jQuery Mobile 类

ruby-on-rails - TinyMCE rails Assets 管道

vba - vlookup错误处理,错误2042

rest - 制作良好的 REST API 请求缓存键的最佳做法是什么?