【发布时间】:2015-02-03 13:13:40
【问题描述】:
我想添加一个 destroyAll 操作来销毁我正在编写的博客应用程序中的所有帖子。我有这样的 routes.rb :
Rails.application.routes.draw do
resources :writings
root "writings#index"
end
在我的控制器内部,我想添加以下操作:
def destroyAll
@writing = Writing.all
@writing.each.destroy
end
请指导我如何向 destroyAll 操作添加路由以及如何在我的视图中使用它来创建使用该操作的链接。
在此先感谢
【问题讨论】:
-
你有一个错误,
@writing.each.destroy错误并引发错误 -
请问我应该用什么替换它?
标签: ruby-on-rails ruby rest model-view-controller