Seems like this is a very common question, and I have followed many of the fixes from google, yet my sign-out problem persists.
Here's what I have: Rails 4.1.1, Devise 3.2.4. Oh, btw, instead of User, I am calling my model AppUser
On view
As AppUser: <br>
<% if app_user_signed_in? %>
Signed in as: <%= current_app_user.email %> <br>
<%= link_to "Sign Out", destroy_app_user_session_path, method: :delete %>
<% else %>
<%= link_to "Sign Up", new_app_user_registration_path %> <br>
<%= link_to "Sign In", new_app_user_session_path %>
<% end %>
/config/routes.rb
Rails.application.routes.draw do
devise_for :app_users
root 'home#index'
end
these are the partial routes from rake routes
Prefix Verb URI Pattern Controller#Action
new_app_user_session GET /app_users/sign_in(.:format) devise/sessions#new
app_user_session POST /app_users/sign_in(.:format) devise/sessions#create
destroy_app_user_session DELETE /app_users/sign_out(.:format) devise/sessions#destroy
on application.js
//= require jquery
//= require jquery_ujs
//= require_tree .
on application.html.erb, i included this as well
<%= javascript_include_tag 'application' %>
and yet, i am still getting the get route error:
No route matches [GET] "/app_users/sign_out"
Why????
Ok. So, changing :delete to :get on /config/initializer/devise.rb fixes the problem, with method: :delete removed of course.
# The default HTTP method used to sign out a resource. Default is :delete.
config.sign_out_via = :get
But I still don't get it? Why? If I were to keep :delete on devise.rb, what was I missing?
========================
[SOLVED] I probably should edit the status update here:
I have finally figured out why. Even though i have set up my javascript, etc, correctly, but it didn't load because I stupidly inherit my controller class from "ActionController::Base" instead of "ApplicationController".
As I was working through my project, I noticed link_tos on other pages weren't able to send :delete method either.
Once I fixed the inheritance, they all work.
Gah.