I am a bit new to Ruby (v2.0.0) on Rails (v4.0.0) and Devise (v3.5.2), and for some reason I cannot Sign Out once I have Signed Up. However, if I manually go into the MySQL2 database and completely delete the user, my Sign Up/Sign In page becomes available again.
I have not touched my session_store.rb initializer or anything else. I am in dire straits and need this fixed before I can move forward.
Help is greatly appreciated.
The logic for my Sign Up form is very simple:
<% if user_signed_in? %>
<%= current_user.email %> / <%= link_to "Sign Out", destroy_user_session_path, method: :delete %>
<% else %>
<%= link_to "Sign Up", new_user_registration_path %> / <%= link_to "Log In", new_user_session_path %>
<% end %>
My devise.rb file is also configured to use :delete :
config.sign_out_via = :delete
I have JQuery in my Gemfile:
# jQuery
gem 'jquery-rails'
gem 'jquery-ui-rails'
And I have them initialized in application.js:
//= require jquery
//= require jquery_ujs
//= require jquery.ui.all
//= require jquery.details
//= require jquery.textchange
My routes.rb is properly configured (the commented out "#devise_for :users" shows that I have tried both methods, none worked) :
Selfstarter::Application.routes.draw do
root :to => 'home#index'
#devise_for :users
devise_for :users do
get '/users/sign_out' => 'devise/sessions#destroy'
end
...
end
And my rake routes reflects that:
Prefix Verb URI Pattern Controller#Action
root GET / home#index
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PATCH /users/password(.:format) devise/passwords#update
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
user_registration POST /users(.:format) devise/registrations#create
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
PATCH /users(.:format) devise/registrations#update
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
user.rb Model:
class User < ActiveRecord::Base
has_many :orders
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end
database.rb just in case it's needed:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: dbname
pool: 5
username: dbusername
password: dbpass
#socket: /opt/local/var/run/mysql5/mysqld.sock
I am at a loss as to what to what steps to take next, and have scoured Google and Stack Overflow. I found nothing.
I also want to mention that I would really want to stick to RESTful conventions, and would not like to use :get methods if at all possible.
EDIT: My Log File
Started DELETE "/users/sign_out" for 127.0.0.1 at 2015-08-21 11:28:17 -0400
Started DELETE "/users/sign_out" for 127.0.0.1 at 2015-08-21 11:28:17 -0400
Processing by Devise::SessionsController#destroy as HTML
Processing by Devise::SessionsController#destroy as HTML
User Load (3.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
User Load (3.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
Can't verify CSRF token authenticity
Can't verify CSRF token authenticity
(1.0ms) BEGIN
(1.0ms) BEGIN
(1.0ms) COMMIT
(1.0ms) COMMIT
Redirected to http://localhost:3000/
Redirected to http://localhost:3000/
Completed 302 Found in 66ms (ActiveRecord: 5.0ms)
Completed 302 Found in 66ms (ActiveRecord: 5.0ms)