简体   繁体   English

Devise签出后获得406

[英]Getting 406 after Devise sign_out

I am using devise (3.1.0.rc2), rails 3.2.6, unicorn and have added 我正在使用devise(3.1.0.rc2),rails 3.2.6,unicorn并添加了

config.to_prepare do
 DeviseController.respond_to :html, :json
end

to my application.rb and am still getting a 406 error when attempting to redirect after logout in my application controller.This is my call 到我的application.rb并在退出我的应用程序控制器后尝试重定向时仍然出现406错误。这是我的电话

<%= link_to 'Logout' , destroy_user_session_path(current_user), confirm: 'Are you sure?', method:'delete' %>

Here is the application controller: 这是应用程序控制器:

class ApplicationController < ActionController::Base

respond_to :json, :html

def after_sign_out_path_for(resource_or_scope)
    Rails.logger.info("logout")
    redirect_to "/"
end

protect_from_forgery
end

Logfile: 日志文件:

Started DELETE "/users/sign_out.4" for 127.0.0.1 at 2013-08-31 08:48:55 -0400
Processing by Devise::SessionsController#destroy as 
Parameters: {"authenticity_token"=>"k2rUBfhoI964j5SQ4Cce9irDxjacFsX614L/XhUtAXM="}
logout
Redirected to http://localhost:4000/
User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = 4 LIMIT 1
(0.2ms) BEGIN
(0.2ms) COMMIT
Completed 406 Not Acceptable in 8ms (ActiveRecord: 1.0ms)

What am I missing? 我想念什么?

It assumed current_user.id as the format. 假定current_user.id为格式。

I was calling 我在打电话

<%= link_to 'Logout' , destroy_user_session_path(current_user), confirm: 'Are you sure?', method:'delete' %>

instead of 代替

<%= link_to 'Logout' , destroy_user_session_path, confirm: 'Are you sure?', method:'delete' %>

destroy_user_session_path(current_user) still works, but it assumes the current_user id as the format. destroy_user_session_path(current_user)仍然有效,但是它假定current_user id为格式。

Credit goes to https://stackoverflow.com/users/588267/jose-valim on github: https://github.com/plataformatec/devise/issues/2209#issuecomment-23605974 幸得https://stackoverflow.com/users/588267/jose-valim GitHub上: https://github.com/plataformatec/devise/issues/2209#issuecomment-23605974

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM