0

Logout functionality does not working properly in "Production Environment".

The logout Function is called in Production Environment by Started GET "/logout" for 127.0.0.1 at 2014-11-11 14:48:52 +0530 instead of Started DELETE "/logout".

Note: I don't use Devise Gem in my application.

routes.rb

 root 'welcome#home'
  get 'signup' => 'users#new'
  get    'login'   => 'sessions#new'
  post   'login'   => 'sessions#create'
  delete 'logout'  => 'sessions#destroy'
  resources :users
   resources :questions
   #resources :choices

 get "quiz/index"

  post "quiz/start"

  get "quiz/question"

  post "quiz/question"

  post "quiz/answer"

  get "quiz/end"

  post "choices/create"

  post "choices/destroy"


resources :sessions, only: [:new, :create, :destroy]  

Logout Code:

<%= link_to "Log out", logout_path , method: "delete"

Note: This code works fine in Development Environment. The problem is with Production Environment itself.

Edited by harry.suren

2
Contributors
2
Replies
10
Views
2 Years
Discussion Span
Last Post by Taywin
0

I have figured the answer for the above Question.

in the "Logout Code" Instead of <%= link_to "Log out", logout_path , method: "delete" use <%= button_to "Log out", logout_path , method: "delete".

This one worked for me.

1

To clarify, "button_to" creates a "form" tag and submit its value (inside its form) to your server (POST). "link_to" is simply a redirect which is similar to an anchor tag in HTML (GET). If you ever deal with submitting a value to your server, use "button_to" and not "link_to" method.

Edited by Taywin

Votes + Comments
Thanks For the Explaination
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.