小编Cra*_*aig的帖子

Rails应用程序在javascript中找不到'destroy_user_session_path'

我有一个rails应用程序,从2.2到3.2开始多年来一直在迁移.我正在使用Devise和Omniauth来使登录工作,不幸的是我认为在迁移期间我搞砸了一些东西.

当我尝试在application.html.erb中设置会话删除时,我收到以下错误:

undefined local variable or method `destroy_user_session_path' for #<#<Class:0xb468e278>:0xb423e1dc>
Run Code Online (Sandbox Code Playgroud)

application.html.erb:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  <title>Coffee Tracker</title>
  <%= stylesheet_link_tag 'application'%>
  <!--%= stylesheet_link_tag 'scaffold' %-->
</head>
<!--%= javascript_include_tag :defaults %-->
<%= javascript_include_tag 'application' %>
<%= csrf_meta_tag %>
...snip...
<% if user_signed_in? %>
  <span id="currentuser"><%= current_user.email %></span>
  <%= link_to('Logout', destroy_user_session_path, :method => 'delete') %>
<% else %>
Run Code Online (Sandbox Code Playgroud)

我尝试这行时也遇到同样的错误:

 <%= link_to('Logout', destroy_user_session_path, :method => :delete) %>
Run Code Online (Sandbox Code Playgroud)

的application.js

// Place your application-specific JavaScript functions and classes here
// This …
Run Code Online (Sandbox Code Playgroud)

javascript ruby ruby-on-rails devise ruby-on-rails-3.2

2
推荐指数
1
解决办法
6121
查看次数