注销在生产环境中不起作用

时间:2014-11-11 09:28:30

标签: ruby-on-rails-4

退出功能在"生产环境"。

中无法正常工作

注销功能在生产环境中由Started GET "/logout" for 127.0.0.1 at 2014-11-11 14:48:52 +0530而不是Started DELETE "/logout"调用。

注意:我不会在我的应用程序中使用Devise Gem。

的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

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]  

退出代码:

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

1 个答案:

答案 0 :(得分:4)

我已经找到了上述问题的答案。

在退出代码中,而不是<%= link_to "Log out", logout_path , method: "delete"使用<%= button_to "Log out", logout_path , method: "delete" %>

这个对我有用。