環境: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的輸出
posted on 2009-05-08 15:07
fl1429 閱讀(1242)
評論(1) 編輯 收藏 所屬分類:
Rails