Rails Rails 只提示 Completed 500 Internal Server Error,不具体提示什么地方错误

fahchen · April 28, 2012 · Last by xranthoar replied at May 02, 2012 · 8684 hits

rails 只提示 Completed 500 Internal Server Error 不具体提示什么地方错误 在别人的电脑上运行出错时能提示什么地方错了 而我的电脑上终端提示 Completed 500 Internal Server Error 页面上是 We're sorry, but something went wrong. 我是装了什么东西才搞成这样的吗? 怎么解决啊,求助

ruby server 没有错误,可能问题就在 web server 上了

#1 楼 @marshluca web server 就是自带的那个 WEBrick,这个需要怎么设置吗?

你部署在什么上的 能看 log 吗 或者说 终端里面 就没有 log 吗

#3 楼 @jhjguxin 终端运行的就是内部错误

Started GET "/votes/new" for 127.0.0.1 at 2012-04-28 12:38:58 +0800 Processing by VotesController#new as HTML Rendered votes/new.html.erb within layouts/application (162.2ms) Completed 500 Internal Server Error in 260ms

可能是因为你是用了 production 模式吧,换回 development 模式就可以看到具体的错误信息了

#5 楼 @paranoyang 是 development 模式

=> Booting WEBrick
=> Rails 3.2.2 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

console 中:

$ rails console
Loading development environment (Rails 3.2.2)
1.9.3p125 :001 > Rails.env
 => "development" 

你需要看你的错误日志,具体可以查看你的 log 目录下的日志文件 通常在 prodution 见的比较多。

#7 楼 @lb563 日志和终端里的是一样的吧? 终端里报错 Started GET "/votes/new" for 127.0.0.1 at 2012-04-28 12:38:58 +0800 Processing by VotesController#new as HTML Rendered votes/new.html.erb within layouts/application (162.2ms) Completed 500 Internal Server Error in 260ms 日志里写的也是一样的 Started GET "/votes/new" for 127.0.0.1 at 2012-04-28 12:38:58 +0800 Processing by VotesController#new as HTML Rendered votes/new.html.erb within layouts/application (162.2ms) Completed 500 Internal Server Error in 260ms

并且 log 下只有一个文件 development.log,应该环境就是 development 吧

#8 楼 @fahchen 我也是新手,常出错。

1:为了确定是否是 development.log 文件你可以刷新页面, 看是否有新的日志输出和输出的时间即可

2:从你的日志并不能直观的看出哪里错了. 我也常遇到这种,给你列出一些我常见的错误吧: 1) 在数据库中没有对应的数据库名, 2) 程序需要的库文件我没有加载 (例如:我自己写在"lib"目录中的文件没有 require 进去) 3) 使用了没有定义的常量 4) 还有很多..

3:你可能尝试贴多一点日志出来,从你贴出来的日志。不好做判断。

@fahchen 还有一个就是编码的问题。如果代码中有中文的话,最好在行首加上"#encoding: utf-8"

#10 楼 @fahchen
看到前面你的操作的:

$ rails consloe # 这个是用 rails 默认的环境,也就是"devlopment"所以你在里面"rails.env" 得到的一定是"devlopment"环境

要看你项目运行的是什么环境?可以在页面显示例在"layouts/application.html.erb"中加上"<%=Rails.env%%>" 这样就可以得到当前项目的运行环境

#11 楼 @lb563 确定是在 development 的环境下,有时能报具体的错,有时就是 we are sorry....但是我把代码拷到别人电脑上就能报具体的错

$ tailf log/development.log 有时候这里会报出来(btw product)也是一样的,而且根据经验一般都是 route 出了问题(不止包括 routes.rb 包括 link_to XX_path 参数什么的不正确) @fahchen

You need to Sign in before reply, if you don't have an account, please Sign up first.