无法使用 Authlogic 路由到 /logout

Can't route to /logout with Authlogic

我一直在尝试使用 Authlogic 在我的应用程序中设置用户身份验证,我确定问题出在我的代码中,但我似乎找不到它。当我点击 /login link 时,一切都按预期工作,但我的 /logout 想要使用 GET 而不是 DELETE。

routing.db

Rails.application.routes.draw do

  root 'comments#index'

  resources :roles
  resources :subjects
  resources :comments
  resources :topics
  resources :users
  resources :user_sessions, only: [:create, :destroy]

  delete '/logout', to: 'user_sessions#destroy', as: :logout
  get '/login', to: 'user_sessions#new', as: :login
end

user_sessions_controller

class UserSessionsController < ApplicationController

  before_filter :require_no_user, :only => [:new, :create]
  before_filter :require_user, :only => :destroy

  def new
    @user_session = UserSession.new
  end

  def create
    @user_session = UserSession.new(user_session_params)
    if @user_session.save
        flash[:success] = "Welcome back!"
        redirect_to root_path
    else
        render :action => :new
    end
  end

  def destroy
    current_user_session.destroy
    flash[:success] = "Goodbye!"
    redirect_to root_path
  end

  private

  def user_session_params
    params.require(:user_session).permit(:username, :password, :remember_me)
  end
end

application.html.erb

<!DOCTYPE html>
<html>
  <head>
    <title><%= content_for?(:title) ? yield(:title) : "Untitled" %></title>
    <%= stylesheet_link_tag "application" %>
    <%= javascript_include_tag :defaults %>
    <%= csrf_meta_tag %>
    <%= yield(:head) %>
  </head>
  <body>
    <div id="user_nav">
        <% if current_user %>
            <span><%= current_user.username %></span>
            <%= link_to "Edit profile", edit_user_path(:current) %>
            <%= link_to 'Sign Out', logout_path, :method => :delete %>
        <% else %>
            <%= link_to "Register", new_user_path %>
            <%= link_to 'Sign In', login_path %>
        <% end %>
    </div>
    <div id="container">
      <% flash.each do |name, msg| %>
        <%= content_tag :div, msg, :id => "flash_#{name}" %>
      <% end %>
      <%= content_tag :h1, yield(:title) if show_title? %>
      <%= yield %>
    </div>
  </body>
</html>

这里有什么地方看起来不对吗?这是我收到的错误:

在您的 application.html.erb 文件中:

变化:

<%= javascript_include_tag :defaults %>

收件人:

<%= javascript_include_tag "application" %>

之后应该可以了!