Ruby on rails 未定义的方法`内容类型';零级:零级

Ruby on rails 未定义的方法`内容类型';零级:零级,ruby-on-rails,Ruby On Rails,diagnostics.erb文件中关于\u set\u controller\u content\u type的奇怪错误 请帮忙 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:

diagnostics.erb文件中关于
\u set\u controller\u content\u type
的奇怪错误

请帮忙

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"=>""}

您试图在控制器中调用的操作是什么


检查控制器中的操作名称

我不知道这是否是你出错的原因。但当我遇到这个错误时,是因为我在控制器中意外地定义了一个“响应”动作。重新命名动作,一切都很好

代码示例:

class PagesController < ApplicationController

  def request
  end

  def response
  end

end
class PagesController
显示返回此错误的代码是的,成功了!我也有类似的问题(在我的控制器中定义了一个响应操作)。重新命名后,现在就像一个符咒。感谢您发布此消息。我出现此错误是因为我定义了“请求”操作。谢谢你在控制器中定义了“响应动作”是什么意思?我犯了同样的错误也是因为我定义了“请求”动作!正如@bcackerman所说。。定义响应操作是什么意思?你能给我一点代码吗?