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

时间:2019-07-03 15:39:50

标签: 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错误的原因是什么?

1 个答案:

答案 0 :(得分:0)

对于任何有类似问题的人,我最后还是查看服务器上的系统日志。在我的发行版上:

sudo tail -f /var/log/messages

这产生了缺少的Ruby错误:

Error during failsafe response: The asset "application_split2" is not present in the asset pipeline.

哪个给了我解决问题的起点。