2016-01-03 54 views
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 

回答

1

do不是ActiveRecord方法。它看起来像你想@item.update。为避免将来出现此类问题,请阅读guidesdocumentation

相关问题