Rails 3.2.13,开发中出现 500 错误,没有日志 [英] Rails 3.2.13, 500 error in development with no log

查看:34
本文介绍了Rails 3.2.13,开发中出现 500 错误,没有日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在迁移 Rails 2.x -> 3.2.13 时遇到问题在某些时候,在修复了一些问题后,我得到 Completed 500 Internal Server Error in 76ms 没有任何回溯.

I've got problem with migrating rails 2.x -> 3.2.13 At some point, after fixing a few things, I get Completed 500 Internal Server Error in 76ms without any traceback.

development.rb

config.consider_all_requests_local       = true
config.action_controller.perform_caching = false

为什么没有回溯以及如何解决这个问题?

Why there is no traceback and how to fix this?

推荐答案

你可能已经解决了它,但我想分享我关于这个问题的几个小时调试,因为它可能非常烦人.简而言之,我遇到了同样的问题 - 500 内部服务器错误,没有抛出任何异常日志.它只发生在动作视图模板中抛出的异常 - 任何 ActionView::Template::Error 异常.例如,缺少部分无效的路由.

you probably solved it but I wanted to share my couple of hours debugging about this issue as it can be very annoying. In short, I was having the same problem - 500 internal server error without any log of the exception thrown. It was happening only for exceptions thrown in the action view templates - any ActionView::Template::Error exception. For example, missing partial, invalid route.

我的具体问题是使用这个 ruby​​ 统计模块:

My specific problem was using this ruby statistics module:

http://derrick.pallas.us/ruby-stats/

直接在 initializers 目录中,这在 rails 2.x 中效果很好.它定义了 Array.sum 方法,该方法已经在 Rails 3 中的 Enumerable.sum 下定义.重新定义的问题在于 Array.sum 不再适用于字符串数组,而 Rails 试图用 ActionView::Template::Error.source_extract 方法处理字符串数组- 当试图在模板中提取错误源时,它使用了以错误方式重新定义的 Enumerable.sum 方法.因此,发生了另一个异常 TypeError: cannot convert String into Fixnum 并且原始异常没有记录,新异常也没有记录.我不得不进行回溯并通过许多内部调用来查看问题出在哪里.

directly in the initializers directory which works great in rails 2.x. It defined Array.sum method which is already defined in rails 3 under Enumerable.sum. The problem with the redefine is that Array.sum no longer works with arrays of strings which is what rails was trying to do with ActionView::Template::Error.source_extract method - when trying to extract the source of the error in template, it uses the Enumerable.sum method which is redefined in a wrong way. Thus, another exception happened TypeError: cannot convert String into Fixnum and the original exception was not logged, neither was the new one. I had to do a backtrace and go through many of the internal calls to see where is the issue.

因此,对于没有看到 ActionView 模板中抛出的实际异常的每个人,请检查您是否没有重新定义在 rails 内部使用的 rails 方法.

So, for everyone not seeing the actual exceptions thrown in your ActionView templates, check if you have not redefined a rails method that is used internally in rails.

这篇关于Rails 3.2.13,开发中出现 500 错误,没有日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆