错误:注销链接中未定义的局部变量或方法`delete'

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了错误:注销链接中未定义的局部变量或方法`delete'相关的知识,希望对你有一定的参考价值。

我正在创建一个登录注销链接。我已经使用我的设计用户并收到以下错误。

显示/home/sushmitha/ground/remote_modals_demo-master/app/views/layouts/_header.html.erb,其中第9行引发:

未定义的局部变量或方法`delete'用于#<#:0x00007f3920c61e38>

//_header.HTML.而不

<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
答案

它应该是方法:: delete。

以上是关于错误:注销链接中未定义的局部变量或方法`delete'的主要内容,如果未能解决你的问题,请参考以下文章

Puma 未定义的局部变量或方法“守护进程”错误

NameError:未定义的局部变量或方法“记录器”

Elastic Beanstalk & Rails - nginx 错误“未定义的局部变量或方法‘location_config_filename’”

Action Mailer NameError:未定义的局部变量或方法“smtp”

控制器中方法的未定义局部变量或方法“env”

getParameter 方法中未定义的变量