0
我在写一个简单的rails应用程序中的edit
方法时遇到了麻烦。在我的update
方法中,我收到一个错误,指出undefined method 'do'
。在轨道控制器中未定义的方法'做'。
我其实有两个问题。首先,我不确定错误是什么,或者如何解决。我的第二个问题是我遇到过这样的错误,但我一直在努力解决它们。有没有关于解决这类错误的有用建议?
这是我的controller
和我的show
页面。我不认为其他任何东西是必要的,但如果需要的话会带来它。
%h1= @item.title
%h3= @item.description
= link_to "Home", root_path
= link_to "Edit", edit_item_path(@item)
= link_to "Delete", item_path(@item), method: :delete, data: {confirm: "Are you sure?"}
我的控制器(I冷凝该部分)
class ItemsController < ApplicationController
before_action :find_item, only: [:show, :edit, :update, :destroy]
def edit
end
def update
if @item.do(items_params)
redirect_to @item
else
render "Edit"
end
end
end