ruby-on-rails – 为什么Ruby 2.5.0在Rails 5.1.4中没有显示堆栈跟踪?

以下是Rails服务器日志的两个示例,用于在仅更改 Ruby版本时遇到的错误.

Ruby 2.4.2,Rails 5.1.4,Puma 3.11.0:

NoMethodError - undefined method `recent' for #<Event:0x00007f08507bf8b8>:
  path/to/show.html.haml:50:in `block in _path_to_show_html_haml___4224769623360811234_28796540'
  path/to/show.html.haml:30:in `_path_to_show_html_haml___4224769623360811234_28796540'

Ruby 2.5.0,Puma 3.11.0:

NoMethodError - undefined method `recent' for #<Event:0x00007f8ccc1b9508>:

如何在Rails日志中重新启用堆栈跟踪?看起来没有办法查看要查看的文件/行号.

为了帮助调查,我将其添加到我的ApplicationController中:

rescue_from Exception do |exception|
  byebug
  1+1
end

Ruby 2.4.2

(byebug) exception.backtrace
# A very large array of paths appears

Ruby 2.5.0

(byebug) exception.backtrace
nil

解决方法

Gemfile中的binding_of_caller gem已过期.我从0.7.3升级到0.8.0,问题就消失了.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...