随笔-167  评论-65  文章-0  trackbacks-0

环境:ruby 1.8.6 + rails 2.1.0 + windows

今天我的rails项目突然不能访问了,出现了 500 Internal Server Error 错误,会了点周折没搞定,看了下rails的log:

/!\ FAILSAFE /!\  Fri May 08 14:00:45 +0800 2009
Status:
500 Internal Server Error
You have a nil object when you didn
't expect it!
The error occurred while evaluating nil.content_type=

于是google了下,网上有这样的问题,但是还就没找到 nil.content_type 的log error,最后我没办法,回到了controller中找找看,后来发现我的controller中有个action命名为了 response 感觉有点不正常,我把这个action改名,果然顺利通过了,怪!...原来命名还需要注意关键字的!

查了下,response不是ruby和rails方法的关键字啊..不知道为什么会出错!

测试了下:

在我的controller中添加了下面的代码:

  def response
puts
'response'
end

测试是客户端每提交一次request,服务器端都执行了这个action,...所以有遇到这个问题的,看是不是你的action命名为response了

 

还有一种出现该错误的,可能是你的Model名字写错了,务必需要仔细一点!..对 500 排错。。最直接的办法 是到log 下 看 log的输出



write by feng
posted on 2009-05-08 15:07 fl1429 阅读(1231) 评论(1)  编辑  收藏 所属分类: Rails

评论:
# re: Rails 500 Internal Server Error[未登录] 2009-05-08 15:10 | javafans
谢谢~~  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航:
 
已访问数:
free counters