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

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

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


 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.

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.

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.

commented: Thanks For the Explaination +0