【发布时间】:2016-04-23 08:34:58
【问题描述】:
目标是移除一个项目;我的印象是我的路线中有错误:
Rails.application.routes.draw do
devise_for :users
resources :users, only: [:show, :destroy]
resources :items, only: [:new, :index, :create, :destroy]
resources :welcome, only: [:index]
get 'items/new'
root 'items#index'
end
部分如下:
<p><%= item.name %></p>
<%= link_to "Done!", root_path, method: :delete, class: 'glyphicon glyphicon-ok' %>
为了以防万一,以下是我的 items_controller 中的销毁操作:
def destroy
@item = Item.find(params[:id])
if @item.destroy
flash[:notice] = "You accomplished a task!"
redirect_to root_path
else
flash.now[:alert] = "There was an error deleting the task. Try again."
end
end
如前所述,我觉得这是我的路线,尽管我已经对它们进行了一段时间的修改。有人看到我误解了什么吗?
谢谢。
【问题讨论】:
标签: ruby-on-rails ruby routes partials