2010-04-27 165 views
5

Diagnostics.erb文件中的奇怪錯誤約爲_set_controller_content_type未定義的方法`content_type'爲零:NilClass

請幫忙。

NoMethodError in Timelines#public_timeline 

Showing /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/templates/rescues/diagnostics.erb where line # raised: 

undefined method `content_type' for nil:NilClass 
Extracted source (around line #): 

RAILS_ROOT: /Volumes/DATA/Source/Rails/tvider 

Application Trace | Framework Trace | Full Trace 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/whiny_nil.rb:52:in `method_missing' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_view/base.rb:331:in `_set_controller_content_type' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_view/renderable.rb:32:in `block in render' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_view/base.rb:306:in `with_template' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_view/renderable.rb:30:in `render' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_view/template.rb:205:in `render_template' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_view/base.rb:265:in `render' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:134:in `rescue_action_locally' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:152:in `rescue_action_without_handler' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:74:in `rescue_action' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:162:in `rescue in perform_action_with_rescue' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:160:in `perform_action_with_rescue' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/flash.rb:146:in `perform_action_with_flash' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in `process' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/filters.rb:606:in `process_with_filters' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/base.rb:391:in `process' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/base.rb:386:in `call' 
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in `call' 
Request 

Parameters: 

None 
Show session dump 

Response 

Headers: 

{"Cache-Control"=>"no-cache", 
"Content-Type"=>""} 
+0

顯示你的代碼,它返回這個錯誤 – fl00r 2010-04-27 13:30:00

回答

2

什麼行動你想在控制器打電話?

檢查控制器中的action_name!

9

我不知道這是你錯誤的原因。但是當我得到這個錯誤時,那是因爲我在我的控制器中不自覺地定義了一個「響應」動作。重命名這個動作,一切都很順利。

+0

是的,這是訣竅!我也有類似的問題(在我的控制器中定義了響應操作)。重命名,現在像一個魅力。感謝您發佈此信息。 – Neovibrant 2012-03-04 09:50:30

+6

我有這個錯誤,因爲我定義了'請求'操作。謝謝 – you786 2012-05-31 18:13:37

+0

你是什麼意思,你在你的控制器中定義了一個「響應動作」? – bcackerman 2012-11-08 00:28:37

相關問題