【发布时间】:2023-03-18 06:10:01
【问题描述】:
这是我的源代码
def update
@recipe = Recipe.find(params[:id])
respond_to do |format|
if @recipe.update_attributes(params[:recipe])
format.html {redirect_to :action => "edit" }
end
end
end
我在这一行得到一个错误
respond_to do |format|
并且错误消息是“您没有预料到它有一个 nil 对象。在评估 nil.call 时发生错误”。
堆栈跟踪中的五行如下
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.4/lib/action_controller/mime_responds.rb:175:in `respond'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.4/lib/action_controller/mime_responds.rb:173:in `each'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.4/lib/action_controller/mime_responds.rb:173:in `respond'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.4/lib/action_controller/mime_responds.rb:107:in `respond_to'
/Path from my machine to the app/app/controllers/recipes_controller.rb:43:in `update'
我不知道如何调试它,也无法理解如何引发此错误。
非常感谢任何帮助。
谢谢
【问题讨论】: