San*_*ser 6 ruby rubygems ruby-on-rails
目前,当我查看 Rails 应用程序的日志文件时,我得到如下堆栈跟踪:
NoMethodError (undefined method `[]' for nil:NilClass):
app/controllers/concerns/example.rb:192:in `rescue in create_example'
app/controllers/concerns/example.rb:163:in `create_example'
app/controllers/concerns/example.rb:11:in `example'
app/controllers/example_controller.rb:39:in `create'
Run Code Online (Sandbox Code Playgroud)
该错误是由作为 gem 包含的第二个项目触发的。在 example.rb 的第 192 行(关注)我们使用了包含的 gem 中的一些类,并且在该类中发生了真正的异常。
另一个例子:
ZeroDivisionError (divided by 0):
app/controllers/dummy_controller.rb:15:in `index'
Run Code Online (Sandbox Code Playgroud)
并在第 15 行
test_object.divide_by_zero
Run Code Online (Sandbox Code Playgroud)
test_object 是包含的 gem 中定义的类的实例
我希望 rails 显示和记录完整的堆栈跟踪,包括所有或特定的 gem,但我不知道如何做到这一点。有人知道怎么做吗?或者有人可以让我朝着正确的方向前进?
谢谢!!!
根据您使用的 Rails 版本,这可能会有所帮助:
http://api.rubyonrails.org/classes/ActiveSupport/BacktraceCleaner.html#method-i-remove_silencers-21