我想添加一個destroyAll操作,它可以銷燬我寫的博客應用程序中的所有帖子。我有我的routes.rb這樣的:添加'destroyAll'動作和路由到我的RESTful rails應用程序
Rails.application.routes.draw do
resources :writings
root "writings#index"
end
我的控制器中我想添加了以下行動:
def destroyAll
@writing = Writing.all
@writing.each.destroy
end
請指導我如何將路由添加到destroyAll行動,以及如何在我的視圖中使用它來建立一個鏈接來使用這個動作。
感謝這麼多提前
你有一個bug,'@ writing.each.destroy'錯誤,提高錯誤 – 2014-12-05 11:52:31
我應該用替換它,好嗎? – 2014-12-05 12:31:40