完全难倒这一点,因为我相信它使用了正确的宁静设置,但我似乎无法删除我的列表。
我有以下内容:
控制器:
def destroy
@list = List.find(params[:id])
@list.destroy
redirect_to lists_path
end
#37 def show
#38 @list = List.find(params[:id])
#39 end
索引.html.haml
- @list.each do |list|
...
= link_to "Delete", list_path(list), method: :delete, data: { confirm: 'Are you certain you want to delete this?' }
...
路线:
ListApp::Application.routes.draw do
devise_for :users
resources :lists
这给出了正确的 rake 路由输出:
lists GET /lists(.:format) lists#index
POST /lists(.:format) lists#create
new_list GET /lists/new(.:format) lists#new
edit_list GET /lists/:id/edit(.:format) lists#edit
list GET /lists/:id(.:format) lists#show
PATCH /lists/:id(.:format) lists#update
PUT /lists/:id(.:format) lists#update
DELETE /lists/:id(.:format) lists#destroy
但是在生产环境中运行时仍然出现以下错误。
I, [2013-09-10T15:27:40.338022 #453] INFO -- : Started GET "/lists/2" for 81.159.35.212 at 2013-09-10 15:27:40 +0000
I, [2013-09-10T15:27:40.340626 #453] INFO -- : Processing by ListsController#show as HTML
I, [2013-09-10T15:27:40.340867 #453] INFO -- : Parameters: {"id"=>"2"}
I, [2013-09-10T15:27:40.354092 #453] INFO -- : Completed 500 Internal Server Error in 13ms
F, [2013-09-10T15:27:40.359807 #453] FATAL -- :
NameError (undefined local variable or method `list' for #<ListsController:0x000000050a7c38>):
app/controllers/lists_controller.rb:38:in `show'
如果有人知道可能导致这种情况的任何帮助将不胜感激:)