0
我是ROR的初學者,我正在關注本教程http://guides.rubyonrails.org/getting_started.html。ROR刪除操作不起作用
因此,根據本教程,我想刪除一篇文章。但它不工作就顯示這個錯誤The action 'destroy' could not be found for PostsController
我交控制器刪除方法看起來像
def destroy
@post = Post.find(params[:id])
logger.debug "***********************: #{@post.id}"
@post.destroy
redirect_to posts_path
end
在路線我提到的資源resources :posts
但它仍然是給錯誤破壞行動。難道我做錯了什麼。需要幫忙。
你如何訪問您的破壞行動?一個相當常見的錯誤是將其作爲HTTP GET而不是HTTP DELETE。例如。 http://stackoverflow.com/questions/18467381/when-calling-destroy-record-is-not-being-removed-from-db/18467444#18467444 – Shadwell
我看到'end'有一個不同的縮進:你確定它匹配'def'?或者它是關閉類定義? – Miotsu
對不起這個可憐的問題。關於'end'。我現在做得很好,現在工作得很好。 – nilkash