我正在创建一个登录注销链接。我已经将设计用于用户并收到以下错误。
在第9行出现的位置显示/home/sushmitha/ground/remote_modals_demo-master/app/views/layouts/_header.html.erb:
#<#:0x00007f3920c61e38>的未定义局部变量或方法'delete'
// __ header.html.erb
<header class="navbar navbar-fixed-top navbar-inverse">
<div class="container">
<h1><%= link_to "Cricket", root_path, id: "logo" %></h1>
<nav>
<ul class="nav navbar-nav navbar-right">
<li><%= link_to "Home", root_path %></li>
<li><%= link_to "Help", '#' %></li>
<% if user_signed_in? %>
<li><%= link_to "Sign out", destroy_user_session_path, method:delete %></li>
<% else %>
<li><%= link_to "Log in", user_session_path %></li>
<% end %>
</ul>
</nav>
</div>
</header>
用户路线
Prefix Verb URI Pattern Controller#Action
new_user_session GET /users/sign_in(.:format) users/sessions#new
user_session POST /users/sign_in(.:format) users/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) users/sessions#destroy
cancel_user_registration GET /users/cancel(.:format) users/registrations#cancel
new_user_registration GET /users/sign_up(.:format) users/registrations#new
edit_user_registration GET /users/edit(.:format) users/registrations#edit
user_registration PATCH /users(.:format) users/registrations#update
PUT /users(.:format) users/registrations#update
DELETE /users(.:format) users/registrations#destroy
POST /users(.:format) users/registrations#create
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PATCH /users/:id(.:format) users#update
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
答案 0 :(得分:1)
应为方法::delete。